jammer6_9
06-13-2007, 01:30 AM
I am trying to hide a row if the value is zero in "Worksheet_Change Event" with this code but my code below doesn't work.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = True
Dim lastrow As Long, r As Long
lastrow = ActiveSheet.UsedRange.Rows.Count
For r = lastrow To 2 Step -1
If UCase(Cells(r, 1).Value) = 0 Then
Cells(r, 1).Select
Selection.EntireRow.Hidden = True
ElseIf UCase(Cells(r, 1).Value) <> 0 Then
Cells(r, 1).Select
Selection.EntireRow.Hidden = False
End If
Next r
End Sub
In addition how can I exclude the hidden row in my calculation using "SUM" formula?
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = True
Dim lastrow As Long, r As Long
lastrow = ActiveSheet.UsedRange.Rows.Count
For r = lastrow To 2 Step -1
If UCase(Cells(r, 1).Value) = 0 Then
Cells(r, 1).Select
Selection.EntireRow.Hidden = True
ElseIf UCase(Cells(r, 1).Value) <> 0 Then
Cells(r, 1).Select
Selection.EntireRow.Hidden = False
End If
Next r
End Sub
In addition how can I exclude the hidden row in my calculation using "SUM" formula?