schang_825
Board Regular
- Joined
- Feb 19, 2010
- Messages
- 66
Hi all,
I have a button in my excel workbook that prompts an input box and creates a new sheet with the text entered. If the user does not enter any text, a message box will appear that tells them they must enter a sheet name. If that name already exists, it tells the user this also.
What I can't seem to do is have a message box appear if the user enters an invalid character such as ? * [ ]. I have this code that only seems to work sometimes:
Dim vaIllegal As Variant
vaIllegal = Array(".", "?", "!", "*", "/", "", "[", "]", "'", ":")
If shtname = vaIllegal Then
InvalidName
Exit Sub
End If
Sub InvalidName()
MsgBox "This is an invalid sheet name! The text cannot contain . ? ! * / [ ] ' or :"
End Sub
Please help!!
I have a button in my excel workbook that prompts an input box and creates a new sheet with the text entered. If the user does not enter any text, a message box will appear that tells them they must enter a sheet name. If that name already exists, it tells the user this also.
What I can't seem to do is have a message box appear if the user enters an invalid character such as ? * [ ]. I have this code that only seems to work sometimes:
Dim vaIllegal As Variant
vaIllegal = Array(".", "?", "!", "*", "/", "", "[", "]", "'", ":")
If shtname = vaIllegal Then
InvalidName
Exit Sub
End If
Sub InvalidName()
MsgBox "This is an invalid sheet name! The text cannot contain . ? ! * / [ ] ' or :"
End Sub
Please help!!