Consulting

Results 1 to 2 of 2

Thread: Loop through charts

  1. #1

    Loop through charts

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Use a For ... Next loop

    [vba]
    Dim chrt As ChartObject

    For Each chrt In ActiveSheet.ChartObjects

    MsgBox chrt.Name
    Next chrt
    [/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

Posting Permissions

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