hiding rows with zero values

  • Thread starter Thread starter Galen
  • Start date Start date
G

Galen

Sub statescleanup()
'
' statescleanup Macro
' hides rows that contain blank values
'

'

For Each i In Sheets("summary").Range("b28:b78")
If i = 0 Then
Row.Select
Selection.EntireRow.Hidden = True
End If

End Sub

doesn't work...
 
Sub statescleanup()
'
' statescleanup Macro
' hides rows that contain blank values
'

'

    For Each i In Sheets("summary").Range("b28:b78")
    If i = 0 Then
    Row.Select
    Selection.EntireRow.Hidden = True
    End If

End Sub

doesn't work...

Galen,

It doesn't work because the computer doesn't know what "Row.Select"
means (nor do I know what it means) and your For loop is missing a
Next. See the code below; the code isn't tested, but it should work
fine.

Best,

Matthew Herbert

Sub StatesCleanup()
Dim rngCell As Range
Dim Rng As Range

Set Rng = Sheets("Summary").Range("B28:B78")

For Each rngCell In Rng.Cells
If rngCell.Value = 0 Then
rngCell.EntireRow.Hidden = True
End If
Next rngCell

MsgBox "Finished Running!"

End Sub
 
thanks that was great
--
Thanks,

Galen


Matthew Herbert said:
Galen,

It doesn't work because the computer doesn't know what "Row.Select"
means (nor do I know what it means) and your For loop is missing a
Next. See the code below; the code isn't tested, but it should work
fine.

Best,

Matthew Herbert

Sub StatesCleanup()
Dim rngCell As Range
Dim Rng As Range

Set Rng = Sheets("Summary").Range("B28:B78")

For Each rngCell In Rng.Cells
If rngCell.Value = 0 Then
rngCell.EntireRow.Hidden = True
End If
Next rngCell

MsgBox "Finished Running!"

End Sub
 
Back
Top