Excel charts and macro problem
Hi,
I'm able to run my macro perfectly well in the workbook that the macro is contained in. However, when I try to run it in another workbook, the macro does not run. I get a:
Run-time error '1004'
Unable to get the Chart Objects property of the Worksheet class
This is the line highlighted:
ActiveSheet.ChartObjects("Chart 2").Activate
Here is the bunch of code that contains that line:
ActiveChart.Axes(xlValue).Select
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
ActiveWindow.Visible = False
Windows("nmmacrosheet.xls").Activate
Range("A26").Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
Selection.Delete
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Delete
ActiveChart.SeriesCollection(1).XValues = "=graphs!R2C10:R361C10"
ActiveChart.SeriesCollection(2).XValues = "=graphs!R2C10:R361C10"
I'd appreciate help with this. I'm guessing that it has to do something with the chart and the workbook.
Thanks,
Neil
Re: Excel charts and macro problem
You try to run it in another workbook, does the other workbook contain the macro code in "ITS" ThisWorkbook class?
If its not in the workbook that your trying to run the macro then it cant see it. Maybe you want to place the macro in your personal
macro workbook?
Re: Excel charts and macro problem
what Robb said, or your worksheet does not contain a 'Chart 2' object
Re: Excel charts and macro problem
Hi,
Thanks for the advice and I am asking for further.
When I try to use the personal macro workbook, I get a message:
Cannot edit a macro in a hidden workbook. Unhide the workbook using the Unhide command.
However, I can't even find that workbook.
Also, is there a way to define the other workbook so that I can have the macro go to that one rather than looking for the workbook that I wrote the macro within? Basically, I am taking a bunch of data from a measurement device which yields an unformatted Excel workbook. The macro that I am writing is supposed to format the sheets into something useable including graphs.
Thanks again,
Neil