Good day every body
I have written a code to search about a worksheet and select it, but when i run the macro it show me the msgbox and when i enter the worksheet name , i press OK and then nothing happens.
Could any body help me in that???
Thanks in advance.
My code is the following:
Sub Macro2()
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim sheetName As String
Dim shn As String
Dim i As Integer
sheetName = InputBox("Please Enter the sheet name")
On Error Resume Next
Set ws = Worksheets(sheetName)
For i = 1 To i <= Worksheets.Count
Set ws2 = Worksheets(i)
shn = ws2.Name
If InStr(shn, sheetName) <> 0 Then
Sheets(sheetName).Select
Range("A1").Select
Else
MsgBox ("Sorry, the sheet name " + sheetName + " not found")
End If
Next i
End Sub
I have written a code to search about a worksheet and select it, but when i run the macro it show me the msgbox and when i enter the worksheet name , i press OK and then nothing happens.
Could any body help me in that???
Thanks in advance.
My code is the following:
Sub Macro2()
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim sheetName As String
Dim shn As String
Dim i As Integer
sheetName = InputBox("Please Enter the sheet name")
On Error Resume Next
Set ws = Worksheets(sheetName)
For i = 1 To i <= Worksheets.Count
Set ws2 = Worksheets(i)
shn = ws2.Name
If InStr(shn, sheetName) <> 0 Then
Sheets(sheetName).Select
Range("A1").Select
Else
MsgBox ("Sorry, the sheet name " + sheetName + " not found")
End If
Next i
End Sub