I use Excel 97. I want to create an Open-High-Low-Close stock chart through a macro. I keep macro recording on; invoke chartwizard; choose Stock; choose OpenHighLowClose; then point to the range, and then click Finish (skipping other details), and then stop recording.
On playing back, this macro does not work. ("Run-time error 1004, Method 'ChartType' of object '_Chart' failed")
It fails on the charttype= statement.
Here is the macro:
' Macro5 Macro
' Macro recorded 28-12-99 by stochastic
ActiveChart.ChartType = xlStockOHLC
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("E12:G16"), PlotBy _
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
However, if I record again, this time by selecting the data range first and then invoking the chartwizard, the rest of the steps same, it works!
The difference in the macro is just the statement
at the start.
Now I would like to avoid the select statement if possible, and logically, it does not seem to be a necessity.
What do you think is the problem?