I am using the following macro code in a spreadsheet to hide rows and it works. However, when I copied it to another spreadsheet I am getting the above error message. The Macro should hide all rows with a 1 in the cell in column AJ. I am very inexperienced with Macros so any help would be fantastic.
Sub HideMyRows()
Application.ScreenUpdating = False
Dim R As Range
With ActiveSheet
For Each R In Range("AJ8:AJ95" & Cells(Rows.Count, 2).End(xlUp).Row)
If R.Value = 1 Then
R.EntireRow.Hidden = True
End If
Next
End With
Application.ScreenUpdating = True
End Sub
Thanks
Bookmarks