hiding rows with zero values

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...
 
M

Matthew Herbert

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
 
G

Galen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top