Thread
:
HELP=What Is Wrong With This Code ?
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
HELP=What Is Wrong With This Code ?
If you want to loop until finding the requested sheet and gothere and quit.
Sub findsheet()
For i = 1 To Sheets.Count
If UCase(Sheets(i).Name) = "PLAYER LIST" Then
Sheets(i).Select
Exit For
End If
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"tommo_blade" wrote in message
...
Hi, for the life of me I cannot see why this wont run, all it needs to
do is loop around a number of sheets in a workook and flag up when it
finds the correct one, the code fails at the "Instr" line, I have also
tried a staright "equals" match, it does not like the object
"Worksheets(x).Name":
WS = 0
For x = 1 To Worksheets.Count
'MsgBox "SHEET:" & Worksheets.Count
If InStr(1, Worksheets(x).Name, "Player List") < 0 Then
MsgBox "FOUND PLAYER LIST:" & x
WS = x
End If
Next x
If WS = 0 Then
MsgBox "Unable to find 'Players List' worksheet"
Else
CODE GOES HERE
thanks..
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett