PDA

View Full Version : Prevent VBA generated charts from refreshing



saxonman
07-17-2007, 06:34 AM
Hi, I have generated a bunch of charts using VBA.
Everything worked fine. However I created those charts based on data that was only temporarily available (while looping thru the macro).
When I hit F9 now all my pretty charts go blank because the data is gone. Anyway to prevent that?
So I am pretty much looking for a vba property that I dont know.

THANKS a lot!!!!

OdiN
07-17-2007, 07:32 AM
Take a screenshot and paste that in? :P

I don't know of a way to do that when the data is gone...it doesn't seem to me that it would work just looking at how charts work, but I haven't done anything in VBA with charts before.

geekgirlau
07-17-2007, 09:42 PM
When you have finished creating the chart, try

Sheet1.ChartObjects("MyChart").CopyPicture

then paste it onto the sheet and delete the chart object.

rory
07-18-2007, 06:10 AM
Hi,
When you create the charts, try running something like this on each one after you have them set up:
Sub ChartVals(cht As Chart)
Dim s As Series
For Each s In cht.SeriesCollection
s.Values = s.Values
s.XValues = s.XValues
Next s
End Sub