Hi everyone,
Could some one advise me how can I make the macro below work faster for me. I am not an expert with macro and found this on internet and modified it to my requirement. Basically what I am trying to do is if the cell value in column C and D is 0, I want those rows hidden. I have 50,000 rows in the sheet. Macro takes about 2-3 minutes to run. Is there any way I can make it quicker.
Sub HideZeroRowsBS1()
Dim lstRw, nxtRw As Long
'Disable Screenupdating
Application.ScreenUpdating = False
'Determine last Row that contains data:
With Sheet59
lstRw = .Range("A" & Rows.Count).End(xlUp).Row
'Unhide all rows
.Rows("2:" & lstRw).Hidden = False
'Loop through rows
For nxtRw = 2 To lstRw
'Hide rows where G:S Sum to 0
If WorksheetFunction.Sum(.Range("C" & nxtRw), _
.Range("D" & nxtRw)) = 0 Then
.Rows(nxtRw).Hidden = True
End If
Next
End With
'Enable Screenupdating
Application.ScreenUpdating = True
End Sub
Display More
Any help with this will be appreciated. Also is it possible to change this macro in a way that I don't have to specify a sheet number, instead it just takes the active sheet. FYI, my range is fixed that I want this macro to look at starting from A2:D50003. Row 1 is heading. I have noticed that if I add any extra column after column D, it makes macro go even slower. Thanks in advance.
Manish