Consulting

Results 1 to 4 of 4

Thread: Prevent VBA generated charts from refreshing

  1. #1

    Prevent VBA generated charts from refreshing

    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!!!!

  2. #2
    VBAX Regular
    Joined
    Jul 2007
    Posts
    71
    Location
    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.

  3. #3
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    When you have finished creating the chart, try

    [vba]Sheet1.ChartObjects("MyChart").CopyPicture[/vba]

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

  4. #4
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Hi,
    When you create the charts, try running something like this on each one after you have them set up:
    [VBA]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
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •