JoyStrassen
New Member
- Joined
- Feb 19, 2024
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
Hi, I am trying to make a for loop that hides sheets if a certain cell says No. The function is only working for one sheet and I can't work out why!
Sub testmacro()
'
For i = 4 To Sheets.Count
Worksheets(i).Activate
If WorksheetFunction.XLookup(Range("O3"), Range("B6:B19"), Range("C6:C19")) = "No" Then
Sheets(4).Visible = False
Else: Sheets(4).Visible = True
End If
Next i
End Sub
Thank you very much in advance!
Sub testmacro()
'
For i = 4 To Sheets.Count
Worksheets(i).Activate
If WorksheetFunction.XLookup(Range("O3"), Range("B6:B19"), Range("C6:C19")) = "No" Then
Sheets(4).Visible = False
Else: Sheets(4).Visible = True
End If
Next i
End Sub
Thank you very much in advance!