I want to be able to create a chart via macro. I can do that ok. The trouble is when I use the macro to create another chart, it uses the data from the last chart. I selected the data before recording the macro thinking that it wouldn't record preselected cells. It seems it does.
Any ideas of how to overcome this?
Thanks
Last edited by Philb1; 09-14-2011 at 07:12 PM. Reason: Solved
Have a look at the code that you have recorded and replace the characters which specify the range that you are plotting with the word Selection.
Suggest posting a copy of the recorded code if you need further help.
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
Hi mrice
I've attached a file showing the symptoms. Cntrl M runs the macro
I've no idea what I'm looking for when in the edit screen
Thanks
Try
Set MyPlotRange = Selection ActiveSheet.Shapes.AddChart.Select ActiveChart.ChartType = xlCylinderColClustered ActiveChart.SetSourceData Source:=MyPlotRange ActiveChart.Parent.Cut Sheets("Sheet2").Select Range("D4").Select ActiveSheet.Paste Range("C4").Select
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
Thanks Martin. Works a treat. I have another question, but I'll start another thread for it.
Cheers
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks