raghuprabhu
Registered User.
- Local time
- Today, 01:58
- Joined
- Mar 24, 2008
- Messages
- 154
Hello Everyone,
I am trying to use an Input Box to prompt member to input a 7 digit number starting with 6, for example, “6014342” to select the worksheet to print. I want to trap error if the number is not 7 digits long or does not start with a “6” or is a blank or an alphabet string.
The following is causing out of range error 9
Private Sub WorkSheetName_Click()
Dim SheetName As String
SheetName = Application.InputBox("Enter a sheet number")
If len(WorkSheetName) <> 7 then
Msgbox ”The number should be 7 digits long!”
Elseif left(WorksheetName, 1) <> 6 then
Msgbox ”The number should begin with 6!”
End if
Sheets(SheetName).PrintOut
MsgBox "Sheet for " & SheetName & " --- Printed!"
End Sub
Please help
Thank you
Raghu
I am trying to use an Input Box to prompt member to input a 7 digit number starting with 6, for example, “6014342” to select the worksheet to print. I want to trap error if the number is not 7 digits long or does not start with a “6” or is a blank or an alphabet string.
The following is causing out of range error 9
Private Sub WorkSheetName_Click()
Dim SheetName As String
SheetName = Application.InputBox("Enter a sheet number")
If len(WorkSheetName) <> 7 then
Msgbox ”The number should be 7 digits long!”
Elseif left(WorksheetName, 1) <> 6 then
Msgbox ”The number should begin with 6!”
End if
Sheets(SheetName).PrintOut
MsgBox "Sheet for " & SheetName & " --- Printed!"
End Sub
Please help
Thank you
Raghu