Search code examples
vbaloopsexcelprogress

vba excel loop_ show iteration number while running (not progress bar)


I have 250.000 lines and I wanted to erase all lines that have a 0 in col AR. This takes too much time using a filter and deleting only visible cells, so I wrote a code. The thing is that I would like to see the progress, but not adding a form, only the number of iteration would be enough.

Is there a way to show the iteration number while running the loop?

My code is:

Sub delrow()

Application.Calculation=xlCalculationManual
Application.ScreenUpdating = False

With Sheets("bners")
LR3 = Range("A" & Rows.Count).End(xlUp).Row
For i3 = 3 To LR3
    a = Sheets("bners").Range("AR" & i3).Value
    If a = 0 Then
    Rows(i3).Delete
    Else
    End If
Next i3
End With

Application.calculate
Application.ScreenUpdating = True

End Sub

Thanks!


Solution

  • I like to use

        count = 0
        For....
          'your code
           count = count + 1
           Application.StatusBar = Count
        next
    

    Displays at the bottom status bar. Simple and to me does not weigh heavy.