Ozgrid Excel Help Forums & Excel Best Practices


XL Templates | XL Add-ins | XL Training | XL Estimating | XL Scheduling | XL Recovery | XL Trading | XL Financial | XL Conversion | XL Charting


<
+ Reply to Thread
Results 1 to 9 of 9

Thread: Animated Chart using a Timer

  1. #1
    Join Date
    10th November 2004
    Posts
    51

    Animated Chart using a Timer

    Hello all,

    I'm experimenting with chart animation using a timer. In this case, the data displayed on the chart depends on

    1. a dropdown box that determines what dataset to get the source data from
    2. a group of checkboxes that determine which series to display

    I already have the code working just fine scrolling through the items in the drop down every 5 seconds. What's not working is that, 5 seconds after the drop down selection is changed, i'd like the first checkbox to get selected, and after another 5 seconds, the second checkbox, and so on.

    This is my code:
    Code:
    Sub AnimateRegions()
    
    Dim AnimationinProgress As Boolean
    Dim r As Long, i As Long
    Dim starttime
    
    If AnimationinProgress Then
            AnimationinProgress = False
            End
        End If
    
        AnimationinProgress = True
    
        UnCheckAll
    
        For r = 1 To 10         'Number of items in the drop down box
            starttime = Timer
            Range("GCQIndex") = r 'Change the selection in the dropdown box through the linked cell
            Compare
            Do While Timer < starttime + 5
                DoEvents
            Loop
            Range("$A$4").Value = Timer
            
            Select Case Timer
                Case starttime + 5
                    Range("$A$25").Value = Timer
                    Range("Compare!ShowCentral").Value = True
                Case starttime + 10
                    Range("$A$25").Value = Timer
                    Range("Compare!ShowNE").Value = True
                Case starttime + 15
                    Range("$A$25").Value = Timer
                    Range("Compare!ShowWest").Value = True
                Case starttime + 20
                    Range("$A$25").Value = Timer
                    Range("Compare!ShowSouth").Value = True
            End Select
            If r <> 10 Then UnCheckAll Else CheckAll
        Next r
        
        AnimationinProgress = False
    End Sub
    Would appreciate your help. I'm doing this to expand my horizons in the Excel Charting/VBA world :D

    Thanks!
    Last edited by gweasley; February 17th, 2005 at 06:05. Reason: SOLVED

  2. #2
    Join Date
    10th November 2004
    Posts
    51

    Re: SOLVED Animated Chart using a Timer

    Quick explanation: this chart depends on what is currently selected in a dropdown box and then the checkboxes which are linked to my selected cells that determine whether the corresponding checkboxes are selected or not.
    This chart will scroll through each question and then check each checkbox one at a time, and then go to the next question in the dropdown.

    To the excel gurus on here, pardon my oft found confused stupidity I'm learning! :D

    To those who are interested, here is my code:

    Code:
    Sub AnimateRegions()
    
    Dim AnimationinProgress As Boolean
    Dim r As Long, i As Long
    Dim starttime, finish, finish2, finish3, finish4, finish5
    
    If AnimationinProgress Then
            AnimationinProgress = False
            End
        End If
    
        AnimationinProgress = True
    
        UnCheckAll
    
        For r = 0 To 9         'Number of items in the drop down box
            starttime = Timer
            Sheets("Compare").ComboBox1.ListIndex = r
            Compare
            Do While Timer < starttime + 3
                DoEvents
            Loop
            finish = Timer
            
            Do While Timer < finish + 3
                DoEvents
            Loop
            Range("Compare!ShowCentral").Value = True
            finish2 = Timer
            
            Do While Timer < finish2 + 3
                DoEvents
            Loop
            Range("Compare!ShowNE").Value = True
            finish3 = Timer
            
            Do While Timer < finish3 + 3
                DoEvents
            Loop
            Range("Compare!ShowSouth").Value = True
            finish4 = Timer
            
            Do While Timer < finish4 + 3
                DoEvents
            Loop
            Range("Compare!ShowWest").Value = True
            finish5 = Timer
            
            Do While Timer < finish5 + 3
                DoEvents
            Loop
            
            If r <> 9 Then UnCheckAll Else CheckAll
        
        Next r
        
        AnimationinProgress = False
    End Sub

  3. #3
    Join Date
    10th November 2004
    Posts
    51

    Re: SOLVED Animated Chart using a Timer

    Question to this - running this animation basically uses up all the system resources and I have to wait till the animation ends. Is there a way to write a macro that would override this or end the animation macro at will short of breaking code execution?

  4. #4
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,319

    Re: SOLVED Animated Chart using a Timer

    Running a macro will use all the resources. There's no multi threading.

    If you can post your workbook I have a quick look see.

    Cheers
    Andy


  5. #5
    Join Date
    10th November 2004
    Posts
    51

    Re: Animated Chart using a Timer

    Here it is, Thanks, Andy!!!

    Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.

  6. #6
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,319

    Re: Animated Chart using a Timer

    I have written 2 routines.
    One to control the stop/starting of animation. The other settings the required data.
    It uses the OnTime method so the code is running for the shortest possible time.
    Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.

    Cheers
    Andy


  7. #7
    Join Date
    10th November 2004
    Posts
    51

    Re: Animated Chart using a Timer

    Hi Andy,

    Thank you so much for your help on this... For some reason, it's not animating in my computer, though the button's caption changes. Anything I should reset/change/set in excel?

    Thanks again,

    ~G

  8. #8
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,319

    Re: Animated Chart using a Timer

    Works for me in xl2k.

    You could check to make sure calculation is set to Automatic.
    Also maybe add the command DoEvents just before it exits the Updatechart routine.

    Cheers
    Andy


  9. #9
    Join Date
    10th November 2004
    Posts
    51

    Re: Animated Chart using a Timer


    Create Excel dashboards quickly with Plug-N-Play reports.
    I have checked into that and it still doesn't work for some reason. I have also tried wringing the neck of my computer (that part which protrudes from the base of the monitor) to no avail :D Must be an internal excel issue we're having (not the first ).

    However, thanks mucho mucho Andy :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Possible Answers

  1. Animated Menus
    By Dave Hawley in forum Excel RSS Feed Discussions
    Replies: 0
    Last Post: November 2nd, 2008, 01:01
  2. Animated Menus
    By Dave Hawley in forum Excel RSS Feed Discussions
    Replies: 0
    Last Post: February 11th, 2008, 03:12
  3. Animated GIF images are not animated in the PowerPoint Viewer
    By Dave Hawley in forum MSDN RSS Feed Discussions
    Replies: 0
    Last Post: December 25th, 2007, 06:55
  4. Animated Menus
    By Dave Hawley in forum Word RSS Feed Discussions
    Replies: 0
    Last Post: November 13th, 2007, 05:14
  5. Animated gif on a userform
    By Ivan F Moala in forum OPEN SOURCE: Hey! That is Cool!
    Replies: 0
    Last Post: March 12th, 2005, 17:03

Bookmarks

Posting Permissions

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