I am using the code below, but it is running into a problem because in some cases the value for sb isn't a sheet name so when it trys to do Sheets(sb).Range("AD2") = Sheets(i).Name it errors.

I would like to make it so that it checks the value of sb to see if it is in list "panel_list" (this list is made up of all the sheet names) I want it to go to the next f if sb is not on "panel_list"

Any help with this would be great.



For i = 9 To Sheets.Count

' Add Distribution Panel Names to List

If Sheets(i).Range("AD3") = "ND" Or Sheets(i).Range("AD3") = "ED" Then

' Add Panel Name and Info to List

For f = 27 To 129
sb = Sheets(i).Range("BX" & f)
If
If sb <> 0 And sb <> "" Then
Sheets(sb).Range("AD2") = Sheets(i).Name
End If
Next f
End If
Next i