pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Can someone please tell me where am i doing it wrong?
I know sheet exist but it keeps telling me it doesnt.
Thanks.
I know sheet exist but it keeps telling me it doesnt.
Thanks.
Code:
[/FONT]
[FONT=Courier New]Private Function SheetExists(sName) As Boolean
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Worksheets(sName)
If Error = 0 Then SheetExists = True Else SheetExists = False
End Function
Sub tryyy()
Dim sName As String[/FONT]
[FONT=Courier New]sName = "OK"[/FONT]
[FONT=Courier New]If Not SheetExists(sName) Then
MsgBox "Nope"
Else
MsgBox "Yes"
Sheets("OK").Select
MsgBox ActiveSheet.Name
End If
End Sub