Compare Worksheet Names - Truncate?
"Vergel Adriano" wrote:
At the top of your code module, put this line
Option Compare Text
What it does is, when you do string comparisons, the compare will not be
case sensitive. So, if there are other parts in your code where "Dates"
should not be the same as "DATES", then this will not work.. Otherwise, with
the Option Compare Text line at the top of your code module, you can have
something like this in your sub procedu
If MyName = "Options" Or _
MyName = "Dates" Or _
MyName = "Scratch" Then
MsgBox "The names, Options, Dates and Scratch are in use. Please
Choose another name for this Worksheet", , "This Name is Reserved."
GoTo NamingRoutine:
End If
it will not allow "Options", "Dates", "Scratch" and any variations in case.
But it will allow Options1 or OptionsJun or DateMay, etc.
--
Hope that helps.
Vergel Adriano
Trader_in_Paradise replies:
Thanks, Vergel
That helps.
I also had success with your InStr function AND Len function combined to
test for Options, Dates, Scratch. The following line works:
ElseIf Len(MyName) = 7 And InStr(1, MyName, "Options", vbTextCompare) 0
Thanks again for all your help. TIP
|