Home » excel » Excel VBA loop and show interactively changes

Excel VBA loop and show interactively changes

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a VBA Application which loops through a range and does some changes.
However, I don’t care much about the running time but I want to show the User that changes were made in run time.

I was thinking about something like this.

Private Sub ProcessALBODY(ByRef Fullpath, ByRef MasterWB)
...

    For Each Row In rng.rows
    ... 'Do Something

    DoEvents
    ActiveWindow.ScrollRow = 1 'for each row scrolldown and proceed to next row
    Next

...
End Sub

Unfortunately my application freezes until it has finished..

How to&Answers:
ActiveWindow.ScrollRow = Row.Row

should do what you want

Answer:

You could use the status bar to show progress. Use Application.StatusBar = and then follow it with your choice of string, integer, etc. If it is put inside the ‘For’ statement, it would update with each iteration.

Answer:

What select or hide not work?

rng.EntireRow.Hidden = True
    For Each row In rng.Rows

        row.EntireRow.Hidden = False
        'do something.
        rng.EntireRow.Hidden = True

    Next

rng.EntireRow.Hidden = False

or

For Each row In rng.Rows

    row.Select
    'do something.

Next