help with debug

J

Jim May

Why is this not working?

Sub FindSheet()
Dim Temp As String
Dim i As Integer
Temp = InputBox("Enter Sheet Name")
For Each Sheet In ActiveWorkbook <<< Bombing here at this line !!
If ActiveSheet.Name = Temp Then
MsgBox "Found the sheet!", vbOKOnly
End If
Next
End Sub

Thanks in Advance,
 
T

Tom Ogilvy

Sub FindSheet()
Dim Temp As String
Dim i As Integer
Temp = InputBox("Enter Sheet Name")
For Each Sht In ActiveWorkbook.Worksheets
If lcase(Sht.Name) = lcase(Temp) Then
MsgBox "Found the sheet!", vbOKOnly
Exit For
End If
Next
End Sub
 
J

Jim May

Thanks Tom; have printed off for "in-depth" study.
It's depressing to have worked with this stuff as long as I have
and to know as little as I do,
we all appreciate your giving-attitude.
Jim
 
Top