0

I have a dashboard I am making. The goal is to query data and refresh the dashboard about every 1 minute. Basically employees are working through a continual flow of work and the dashboard needs to query data, replace the data in the dashboard, refresh the dashboard visual so the change can be seen, wait about a minute, and repeat the whole process including the query.

I have everything working EXCEPT it's looping through the iterations but not refreshing. I need this loop to stop once a cycle and display the updates. What it's doing now is looping but its frozen essentially until I press Esc. Any code that can make this loop stop for a second so it can visually display what has changed since the last loop iteration?

The dashboard is named Summary in the VBA properties.

Any Suggestions? Thanks!!!

For cycle_count = 1 To cycles
        Application.ScreenUpdating = False
        Summary.Range("F3").Value = cycle_count
        
        If cycle_count > 1 Then
                    Application.Wait (Now + TimeValue("0:00:45"))
        End If
        
        Calculate
        
        SQL_MR.SQL_MR
        SQL_Issues.SQL_Issue_Import
        
        If Not Application.CalculationState = xlDone Then
                    DoEvents
        End If
        
        Calculate
        
        Summary_Build.service_window
        
        Application.ScreenUpdating = True
        Summary.Activate
        

Next

Victor
  • 5,142
  • 4
  • 12
  • 29
Mitsugi
  • 67
  • 1
  • 1
  • 5
  • 1
    try a **DoEvents** statement after the ScreenUpdating = true – igittr Dec 13 '21 at 17:14
  • Unfortunately this did not work. I thought it was but it didn't. I have a cycle counter on the dashboard and it said "15" and after I pressed ESC it immediately displayed 25. So it wasn't refreshing. Any other ideas? Thanks! – Mitsugi Dec 14 '21 at 01:42
  • is the dashboard on a Form, if so follow the DoEvents with a **Me.Repaint** to hopefully redraw the form. – igittr Dec 14 '21 at 13:37
  • It isn't a form. It's just an excel worksheet. The VBA is clearing contents and inserting values from a refreshed query into the cleared cells. – Mitsugi Dec 14 '21 at 14:44
  • explore this post [https://stackoverflow.com/questions/3735378/force-a-screen-update-in-excel-vba](https://stackoverflow.com/questions/3735378/force-a-screen-update-in-excel-vba) – igittr Dec 15 '21 at 15:11

0 Answers0