Dear Expert,
I write a code below to jump to specific sheet.
Sub test()
Dim i As integer
i = applcation.inputBox("Enter worksheet number", "sheet selection",type=:1)
MsgBox "Sheet " & i & "selected!"
Sheets("Sheet" & i).Select
End sub
Please kindly comments if any moderate or new method
Regards,
Hi rathanak
Your code will cause an error if user press ESC/Cancel or enter a non-existence sheet number.
I have modified your code so give it a try. It will allow you to select by the worksheet's name instead of number.
Sub SelectSheet()
Dim i As Variant
Dim ws As Worksheet
i = Application.InputBox("Enter worksheet name", "Select sheet")
'Cancel was pressed
If i = False Or Trim(i) = "" Then Exit Sub
'Check if sheet exist
On Error Resume Next
Set ws = Sheets(i)
On Error GoTo 0
If ws Is Nothing Then
MsgBox "Worksheet " & i & " not found!"
Else
Sheets(i).Select
MsgBox "Worksheet " & Sheets(i).Name & " selected!"
End If
End Sub
Thanks Suuny,you're so awesome
Thanks Sunny you are beautiful to create this Select Sheets Macro
As too many sheets in a wrokbook sometimes make us confuse and easily get lost or how to be the desired Sheet effectively.
I write a little bit macro too to list all sheet then using your Selected Sheet Macro , now make life a lot easier.
Now can go home earlier have some sleep..
Hi David
Happy to know you find the macro useful and have modified it to list all worksheets in the workbook for easier selection.
Enjoy your sleep....Z Z Z Z Z Z Z Z Z Z
Sunny