I am using a 'Worksheet_Change' event in a macro that takes about 15-20 seconds to run each time a user selects an option in a dropdown due to accessing a large data range. I want to show a very basic % complete status in Excel to let the user know it is processing. Using the default Excel Application.StatusBar would suffice, but it is not visible on my workbook.
My working hide/show columns macro:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R, V
If Target.Address = ("$K$7") Then
V = [K7].Value
For Each R In Range("R3:GJU3")
If IsError(R.Value) Then
R.EntireColumn.Hidden = True
Else
R.EntireColumn.Hidden = R.Value <> V
End If
Next
End If
End Sub
I found the code below on a separate thread, but am unsure how to modify for my purposes based on my macro above.
Code below credit to @eykanal at Progress bar in VBA Excel
Option Explicit
Sub StatusBar()
Dim x As Integer
Dim MyTimer As Double
'Change this loop as needed.
For x = 1 To 250
'Dummy Loop here just to waste time.
'Replace this loop with your actual code.
MyTimer = Timer
Do
Loop While Timer - MyTimer < 0.03
Application.StatusBar = "Progress: " & x & " of 250: " & Format(x / 250, "Percent")
DoEvents
Next x
Application.StatusBar = False
End Sub