View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default HELP=What Is Wrong With This Code ?

ONLY change where I have 'other code here. Delete my test line of
Range("e21").Value = 211

Sub findsheet()
Dim i As Long
For i = 1 To Sheets.Count
If UCase(Sheets(i).Name) = "PLAYER LIST" Then
Sheets(i).Select
Exit For
End If
Next i
Range("e21").Value = 211
'other code here
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"tommo_blade" wrote in message
...
that does not work either, now fails at the line with the "Ucase"
statement, I get the error when I select my worksheet, the vba code
behind the worksheets calls this piece of code.

the error is a run-time error '57121':
Application-defined or Object-defines error


Public Sub PopulateDropDowns()

Dim WS As Integer
Dim i As Integer
Dim y As Integer

WS = 0

For i = 1 To Sheets.Count
If UCase(Sheets(i).Name) = "PLAYER LIST" Then
Sheets(i).Select
'MsgBox "FOUND PLAYER LIST:" & Sheets(i).Name
WS = i
Exit For
End If
Next i

If WS = 0 Then
MsgBox "Unable to find 'Players List' worksheet"
Exit Sub
Else

== CODE HERE <==

end Sub