PDA

View Full Version : Loop through charts



chil24
03-28-2010, 10:28 AM
Hi
I want to make a macro that one time a day updates my excel with new data and continuously cycles through my charts.
Its to be used for a presentation on a big screen where people occasionally will have meetings going through the charts.

I have used the ontime function so the users can maneuver through the charts even though the macro is still running.

My only problem is that i cant get my charts to keep looping.
I use the ActiveChart.Next.Select so when it comes to the last chart the macro stops.

How can i make the code keep looping through the charts?



Sub refresh()


dTime = Now + TimeValue("00:01:00")
dTime2 = TimeValue("18:00:00")

Application.OnTime dTime, "refresh"
Application.OnTime dTime2, "update"

ActiveChart.Next.Select

End Sub


Sub Killitall()

Application.OnTime dTime, "refresh", , False
Application.OnTime dTime2, "refresh", , False



End Sub


Sub update()

If Run("mynewdata", True) = 1 Then
Else
End If

End Sub

Bob Phillips
03-28-2010, 10:46 AM
Use a For ... Next loop


Dim chrt As ChartObject

For Each chrt In ActiveSheet.ChartObjects

MsgBox chrt.Name
Next chrt