Sheet Name question

  • Thread starter Thread starter S G Booth
  • Start date Start date
S

S G Booth

I need to check for a worksheet's name, and need to be sure that all the
following example names will be valid:
SHEET ....... Sheet......... or sheet

guess that's a load of "sheet"!

Can I do this reliably with UCase, or ?

If (UCase(.Name) =

Regards.
 
if strcomp(sh.name,"sheet",vbTextCompare) = 0 then

or

if lcase(sh.name) = "sheet" then

or

if ucase(sh.name) = "SHEET" then
 
You should be able to accomplish this with the "Ucase" command.

if ucase(Activesheet.name)="SHEET" THEN msgbox ("matches")
 
Since the application doesn't allow for the same sheet name, regardless of
the character case, using UCase() would work well. You might want to use
UCase() on both sides of a comparison, e.g.,

UCase(Sheets(i).Name) = UCase(MySheetVariableName)

Good luck,
VBA Dabbler
 
Many thanks to you all.

It seems I must test for each of the 3 possibilities.

However, I thought I had read somewhere that UCase could be used with a
mixture of upper and lower case characters.

Regards and thanks.
 
you didn't understand. You can use anyone of the the three tests I provided
the OR was not code, but prose.

All three methods, as presented, are case insensitive.
 
S G Booth said:
I need to check for a worksheet's name, and need to be sure that all the
following example names will be valid:
SHEET ....... Sheet......... or sheet

guess that's a load of "sheet"!

Can I do this reliably with UCase, or ?

If (UCase(.Name) =

Regards.

Valid? What name would make a sheet's name invalid???

/ Fredrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top