I have an excel file with a LOT of worksheets, and i wanted to run a macro that would hide a range of rows based on the value at the top of this range. My macro works, but since i have a ton or worksheets, it is taking forever to run...
Can somebody help me in optimizing it, because i may have done things unorthox-ly...
Sub MasquerPrix()
Dim RowNum As Long
Dim StartRow As Long
Dim ColNum As Long
Columns("D:H").Select
Range("F1").Activate
Selection.EntireColumn.Hidden = False
Columns("E:F").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
StartRow = 1
RowNum = 1
ColNum = 2
Do While Cells(RowNum, ColNum).Value <> "Prix Total (Public HT)"
If Cells(RowNum, ColNum).Value <> "Prix Total (Public HT)" Then
Rows(RowNum).Resize(12).EntireRow.Hidden = True
Rows(StartRow & ":" & (RowNum)).EntireRow.Hidden = False
End If
RowNum = RowNum + 1
Loop
End Sub
Thanks a million !