0

I am running a lot of code for creating some reports.

To see how far the creation of reports has proceeded, I want to show a loading bar on my control sheet.

Therefore I use conditional formatting to create a loading bar in a cell. When a report (=a worksheet) is finished with calculating, the loading bar has reached 100% (full).

The problem I have now shows in updating these loading bars.

When running my code, different macros are executed. The loading bars work for 4-5 Macros, after that the screen freezes until all macros are finished. Where is the problem here?

The filling of the progress bar is done by another macro that turns on screenupdating, sets a new progress value on the sheet and turns screenupdating off.

R3uK
  • 14,417
  • 7
  • 43
  • 77
Andi
  • 124
  • 2
  • 12
  • 1
    Possible duplicate of [Force a screen update in Excel VBA](http://stackoverflow.com/questions/3735378/force-a-screen-update-in-excel-vba) – Preston Feb 03 '17 at 13:33

2 Answers2

2

I recently added a Progress Indicator form to one of my files.

I created a UserForm, added a frame, and a label inside that frame, and a couple of other labels that I could update with specifics later.

enter image description here

I load the userform at the start, and pass the % that has completed and what I want the labels to say to this

Public Sub ProgressUpdate(ByVal dCalc As Double, ByVal Process As String)
  With ProgIndi
    If .Visible Then
      .Process.Caption = Process & "..."
      .PercentCompleted.Caption = Int(dCalc * 100) & "% Completed." 
      .Bar.Width = dCalc * 200                                      
      DoEvents                                                      
    End If
  End With
End Sub

At the end of the macro, unload the form. You can leave the ScreenUpdating at False and the form still updates.

Rdster
  • 1,846
  • 1
  • 16
  • 30
0

Put DoEvents in your loop so that Excel 'catches up' with any actions

Put .Repaint in your loop for your form so that the form itself updates

Jiminy Cricket
  • 1,377
  • 2
  • 15
  • 24