PDA

View Full Version : [SOLVED:] Chartobject appears with 30+series already plotted



clvestin
08-06-2005, 05:20 AM
After a sort I copy and paste the sorted data to different sheets. I then request thru a listbox what data the user would like to chart.
When the first chartobject is embedded on the sheet containing that data, the 50+ columns of data on that sheet are plotted.(aren't they suppose to be an empty object, a frame holder only?)
I've tried various unselect/reselect commands and using a DLL EmptyClipboard to no avail.
I have made the routine work,but i must copy the data fot the first chart just to place it the clipboard queue ahead of the previous copied data(i presume)

Any thoughts would be appreciated. The routine now works, but i still get an original plot of the many series before its replaced with the one i want.
Hope this is clear enough to describe the problem.

Jacob Hilderbrand
08-06-2005, 11:48 AM
What aren you setting the source data to when you make the chart? Can you post the code and / or an attachment for us to take a closer look at?

JonPeltier
08-13-2005, 12:09 PM
How are you adding the chartobject? If you use cleaned up macro recorder code, you're probably adding a chart sheet, then embedding the chart sheet in another sheet. When you create a chart sheet without specifying a particular source data range, it matters what is in the active cell. If the selection is in the data range, or it contains no data but is multiple cells in size, that selection is used as the chart source data range. If a single blank cell is selected, the chart will have no source data. If you forgot to delete the source data range from the recorded macro, that's what it will use.

If you create a chart object directly by using Sheet.ChartObjects.Add(l,t,w,h), where l,t,w,h are the left, top, width, and height of the new chart object, there is no source data range defined.

clvestin
09-08-2005, 05:40 AM
Sorry for the untimely reply.
Yes, I am using the ChartObjects.Add method. However rather than use a crude Copy and Paste method of moving the data, I switched to the

Sheet1.Rows.Range("a" & crow, "a" & drow - 1).EntireRow.Copy Destination:=Worksheets(shtname(t)).Range("a1:a1").

This has eliminated the wealth of data on the clipboard(I think?).

Nonetheless, never satisfied with my own answers, why did this matter. The ChartObject.Add should produce an empty object. Any thoughts??

JonPeltier
09-08-2005, 06:33 AM
ChartObjects.Add() does produce an empty object if there is nothing in the clipboard. It doesn't matter what is selected. Just before adding the chartobject, insert this line to clear the clipboard:


Application.CutCopyMode = False

and you should get your blank chart.

clvestin
09-08-2005, 07:17 PM
Thx for the help, Jon

JonPeltier
09-08-2005, 07:32 PM
Glad to help. I like to see them "Solved".