This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I 'm building a dashboard with animated charts displaying financial positions over time. The data for the chart changes based on a date value within a cell which has forecast to date/spend to date/total budget data pulled from a master sheet which uses a SUM/OFFSET/MATCH combination which corresponds to the month values.
I've written a macro which changes this date value based on a time interval and is started when a shape marked "start" is clicked. The Macro functions and the charts update periodically, but there's an issue with clicking the button again to stop the code running and it just loops indefinitely. I'm sure I'm close, I just can't work out where I've gone wrong. Any advice would be much appreciated on how I can get it to stop without a CTRL Break? I'm sure there's a more efficient way of running the code but it is functional. See Below.
Dim Stopped As Boolean
Dim i As Integer
Option Explicit
Sub ChartAnimator()
If Range("A1") = "START" Then
Range("A1") = "STOP"
Stopped = False
Do Until Stopped Or i = 10
For i = -1 To 10
DoEvents
DoEvents
Application.Wait (Now TimeValue("0:00:02"))
Range("A18").Formula = "=EOMONTH(DATE(2018,4,1)," & i & ") 1" 'inserts 1st day of month,
starting at Apr 18 to Mar 19
DoEvents
DoEvents
Next i
Loop
Else
Stopped = True
Range("A1") = "START"
End If
End Sub
Subreddit
Post Details
- Posted
- 6 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/excel/comme...