Im still a beginner when it comes to VBA and I'm trying to write a code that hides rows if its cell value equals zero and the user has chosen to set another cell value to the correct wording. However, the code I wrote doesn't seem to work; I'm sure I have forgotten to add something or am missing some key element but can't seem to figure out what it is.
I have posted my code below. Any help would be much appreciated.
Sub HideEmptyRows()
Application.EnableEvents = False
Worksheets("Filtered Data").Rows("7:600").EntireRow.Hidden = False
If Range("J7") = "Filter" Then
For Each cell In Range("J10:J503")
If cell.Value = 0 Then
cell.EntireRow.Hidden = True
End If
Next cell
Application.EnableEvents = True
End Sub