For Each in VBA in Excel

I am trying to create a macro in Excel that will take a look at the values in range C7:C4000 and if the value is equal to 0, to then hide that row. Currently my macro is erring out, but I'm not sure why. Here is what I have:

Sub hide_zero()

Dim rng As Range
Dim cell As Variant

Set rng = Range("C7:C4000")

For Each cell In rng.cell
If cell.Value = 0 Then selection.EntireRow.Hidden = True
Next

End Sub

Nick's picture

Try this: Sub

Try this:
Sub hide_zero()
 
Dim rng As Range
Dim cell As Variant
 
Set rng = Range("C7:C4000")
 
For Each cell In rng
 If cell.Value = 0 Then 
  cell.EntireRow.Hidden = True
 endif
Next
 
End Sub