V.Hunon
V.Hunon

Reputation: 320

Excel VBA loop and show interactively changes

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..

Upvotes: 1

Views: 71

Answers (3)

pgSystemTester
pgSystemTester

Reputation: 9917

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

Upvotes: 0

Tim Williams
Tim Williams

Reputation: 166256

ActiveWindow.ScrollRow = Row.Row

should do what you want

Upvotes: 2

GarrettS1
GarrettS1

Reputation: 66

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.

Upvotes: 0

Related Questions