Excel VBA - requesting opinion
So I have an Excel file with 140 identical tabs with 76 rows on each tab that contain information. Some of the rows, however, don't necessarily contain any useful information so I would like to hide them. Therefore, I wrote a formula in Column A that will show "HIDE" or "SHOW" depending on whether or not I want it to appear.
Then, I wrote a VBA macro to go through all the rows in all the tabs and hide those leading with "HIDE" but the pain point is that this macro takes 3-5 hours and that's ridiculous!!
So I was hoping to solicit a second opinion on what could be done to speed up macro and achieve the same end goal (hiding rows without important info - likely by depending on a binary formula).
Thanks! I really appreciate any and all input!
Best,
Eric
==================================================================
Sub HideRows()
Dim wsMap As Worksheet
Dim wsTab As Worksheet
Dim iRow As Integer
Dim iTabRow As Integer
Dim sStartTime As String
Dim sEndTime As String
Application.ScreenUpdating = False
Set wsMap = ActiveWorkbook.Sheets("Map")
sStartTime = Time
iRow = 3
Do While wsMap.Cells(iRow, 7).Value <> ""
Set wsTab = Worksheets(wsMap.Cells(iRow, 8).Value)
iTabRow = 11
Do While wsTab.Cells(iTabRow, 1).Value <> ""
If wsTab.Cells(iTabRow, 1).Value = "Hide" Then
wsTab.Rows(iTabRow).Hidden = "True"
Else
wsTab.Rows(iTabRow).Hidden = "False"
End If
iTabRow = iTabRow + 1
Loop
iRow = iRow + 1
Loop
Application.ScreenUpdating = True
sEndTime = Time
MsgBox ("Hide Rows Macro" & vbCrLf & _
"Start Time: " & sStartTime & vbCrLf & _
"End Time: " & sEndTime)
End Sub
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago