I am trying to write a Macro in Excel VBA whereas any row under C2 gets hidden if the cell text contains "hide". I want the entire column to be evaluated no matter how many cells are filled (hence why LastRow is goes until the end). Don't know why this isn't working - it tells me I have a type mismatch. Can someone help pls
Sub Hide()
Worksheets("Sheet1").Activate
StartRow = Range("C2")
LastRow = Range("C2", Range("C2").End(xlDown))
For i = StartRow To LastRow
If Cells(i, iCol).Value <> "hide" Then
Cells(i, iCol).EntireRow.Hidden = False
Else
Cells(i, iCol).EntireRow.Hidden = True
End If
Next i
End Sub