PDA

View Full Version : Solved: Graphs to update



asingh
02-17-2008, 05:29 AM
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

Bob Phillips
02-17-2008, 08:12 AM
But chart does



ActiveSheet.ChartObjects("Chart 1").Chart.Refresh

asingh
02-17-2008, 09:04 AM
But chart does



ActiveSheet.ChartObjects("Chart 1").Chart.Refresh


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

Bob Phillips
02-17-2008, 09:22 AM
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.

asingh
02-17-2008, 03:24 PM
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

asingh
02-17-2008, 04:06 PM
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