Sub HideRows()
Dim R As Long
Dim Rng As Range
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange
End If
For R = 1 To Rng.Rows.Count
If Application.Sum(Range(Rng(R, 3), Rng(R, Rng.Columns.Count))) = 0# Then
Rng.Rows(R).Hidden = True
End If
Next R
End Sub
Hi,
I am looking for VBA codes to hide rows for which sum is zero. I googled it and found the following codes.
"Sub HideRows()Dim R As Long
Dim Rng As Range
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange
End If
For R = 1 To Rng.Rows.Count
If Application.Sum(Range(Rng(R, 3), Rng(R, Rng.Columns.Count))) = 0# Then
Rng.Rows(R).Hidden = True
End If
Next R
End Sub"
The above code also hides blank rows. I dont want that. Someone responded to do the following;
"replace the FOR loop in each method with this....
myRange = Range(Rng(R, 3), Rng(R, Rng.Columns.Count))
For R = 1 To Rng.Rows.Count
If Application.CountBlank(myRange) <> myRange.Cells.Count Then
If Application.Sum(myRange) = 0# Then
Rng.Rows(R).Hidden = True
End If
Next R"
I dont know how to do this. I am a dummy when it comes to programming.
This hides blank rows as well. I am working on huge data where i want to the blank rows to be shown. Could some one help.
Dim R As Long
Dim Rng As Range
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange
End If
For R = 1 To Rng.Rows.Count
If Application.Sum(Range(Rng(R, 3), Rng(R, Rng.Columns.Count))) = 0# Then
Rng.Rows(R).Hidden = True
End If
Next R
End Sub
Hi,
I am looking for VBA codes to hide rows for which sum is zero. I googled it and found the following codes.
"Sub HideRows()Dim R As Long
Dim Rng As Range
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange
End If
For R = 1 To Rng.Rows.Count
If Application.Sum(Range(Rng(R, 3), Rng(R, Rng.Columns.Count))) = 0# Then
Rng.Rows(R).Hidden = True
End If
Next R
End Sub"
The above code also hides blank rows. I dont want that. Someone responded to do the following;
"replace the FOR loop in each method with this....
myRange = Range(Rng(R, 3), Rng(R, Rng.Columns.Count))
For R = 1 To Rng.Rows.Count
If Application.CountBlank(myRange) <> myRange.Cells.Count Then
If Application.Sum(myRange) = 0# Then
Rng.Rows(R).Hidden = True
End If
Next R"
I dont know how to do this. I am a dummy when it comes to programming.
This hides blank rows as well. I am working on huge data where i want to the blank rows to be shown. Could some one help.