Formating between lower case and upper case..A puzzle

Formating between lower case and upper case..A puzzle

Post by Samantha Macdonal » Mon, 02 Jul 2001 07:34:25



Hello,

I have a question.

How do I format this command so that when it looks at the cell, it will
recognize both lower case and uper case.

Mystr = "D2"

If Left(h, Len(myStr)) = myStr Then

This if loop looks at a string, lets say "D2" and does something to it.
However if the cell reads "d2", it ignores it. Can
someone hlep format this statement so that it recognizes both "d2" and "D2"

Thank you,

Samantha

 
 
 

Formating between lower case and upper case..A puzzle

Post by Ivar » Mon, 02 Jul 2001 09:00:23


Assuming you're using Excel, Visual Basic for Applications (VBA).

1. Make the test string uppercase, then use UCASE:

Mystr = "D2"
If UCase(Left(h, Len(myStr))) = myStr Then

2. Or use StrComp(String1,String2, Type) which returns 0 (zero) if the two
strings match.  The comparison is not case-sensitive when Type is set to 1.

If StrComp(Left(h, Len(myStr)), myStr, 1) = 0 Then

3. Or put this statement at the module level to declare the default comparison
method to be case-insensitive:

Option Compare Text

Quote:>How do I format this command so that when it looks at the cell, it will
>recognize both lower case and uper case.

>Mystr = "D2"

>If Left(h, Len(myStr)) = myStr Then

>This if loop looks at a string, lets say "D2" and does something to it.
>However if the cell reads "d2", it ignores it. Can
>someone hlep format this statement so that it recognizes both "d2" and "D2"


 
 
 

Formating between lower case and upper case..A puzzle

Post by CycleZe » Tue, 03 Jul 2001 09:06:59


You can convert h to upper case with the Ucase() function:
If Ucase(Left(h, Len(myStr))) = myStr Then

HTH,
Dave O


Quote:> Hello,

> I have a question.

> How do I format this command so that when it looks at the cell, it will
> recognize both lower case and uper case.

> Mystr = "D2"

> If Left(h, Len(myStr)) = myStr Then

> This if loop looks at a string, lets say "D2" and does something to it.
> However if the cell reads "d2", it ignores it. Can
> someone hlep format this statement so that it recognizes both "d2" and
"D2"

> Thank you,

> Samantha