Consulting

Results 1 to 6 of 6

Thread: Solved: Graphs to update

  1. #1
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location

    Solved: Graphs to update

    Hi,

    I have a sheet which has around 5 data grids on it.

    Say: Column A has City names, Column B has a calculated number, and Column C has the % contribution of the column B number overall. And my graphs are bound to column A and Column C. After the sheet calculates I want the Graph to show the values in Descending order..somewhat like a pareto graph. To do this I sort the whole data grid based on column C (%) - in descending order. To get the graph to update I have to recalculate the sheet. Now one recalculation is taking around 8 minutes.

    Is there anyway that after the sorting is done (will write the code for this) -- that I dont need to force another recalculation on the sheet, and the graphs update after after the grids have been sorted as per %. The "charts" object does not have any refresh/update property. But "active chart" does...this way I will have to select each chart..!!

    thanks and regard,

    asingh

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    But chart does

    [vba]

    ActiveSheet.ChartObjects("Chart 1").Chart.Refresh
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Quote Originally Posted by xld
    But chart does

    [vba]

    ActiveSheet.ChartObjects("Chart 1").Chart.Refresh
    [/vba]
    I am sure this will work..but is there any way that all the charts on the active sheet get refreshed...without having to hard code in "Chart 1". Or it dynamically loops through all charts found on a sheet.

    Else I will create a loop and cycle through each chart........!!!!

    thanks,

    asingh

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Well I don't have a problem with it being automatic if the chart is bound to the data, but you did, so I showed you how to use Refresh on a nominated chart.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Ok..I tried this...

    Dim myChart as ChartObject
    Dim myCharts as ChartObjects
    Dim myChartname as string
    
    Set myCharts = ActiveSheet.ChartObjects
    
    For Each myChart in myCharts
      myChartname = myChart.Name
      ActiveSheet.ChartObjects(myChartname).Chart.Refresh
    Next
    The code is cycling through each graph fine..on the active sheets...but the graphs are not refreshing. Though if I press a F9..the graphs then update....

    This way I do not need to hard-code in the chart names...?? What could be the problem here..?

    regards.
    asingh

  6. #6
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Hi,

    It is working now....at the end of the program I had a message box. I removed that..and now the graphs are refreshing...weird...!!

    thanks...

    regards,

    asingh

Posting Permissions

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