> As others have pointed out, you needed to use "String", not "string".
> Whenever you do a logical test against a String constant (text within
[quoted text clipped - 26 lines]
>>> MsgBox (TypeName(ActiveCell.Value) = "string") 'Displays 'FALSE'
>>> End Sub
When comparing strings, I usually use StrComp rather than the "="
operator. With StrComp, you can specify whether the comparison is
case-sensitive, regardless of the Option Compare setting of the
module. E.g.,
If StrComp(VarName, "AbCd", vbTextCompare) = 0 Then
' strings match
Else
' string do not match
End If
Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email is on the web site)
USA Central Daylight Time (-5:00 GMT)
>Along similar lines, to avoid case sensitivity with string comparisons could
>head the module -
[quoted text clipped - 36 lines]
>>>> MsgBox (TypeName(ActiveCell.Value) = "string") 'Displays 'FALSE'
>>>> End Sub
Rick Rothstein - 12 Oct 2008 16:54 GMT
The only thing I don't like about using StrComp is it uses 0 for equality.
Of course, I understand why... it makes perfect sense when you consider it
uses +1 for greater than and -1 for less than... but my mind always equates
0 with False in logical comparisons and so, when checking for string
equality, testing StrComp to 0 (a False type value) just seems so wrong to
me.

Signature
Rick (MVP - Excel)
> When comparing strings, I usually use StrComp rather than the "="
> operator. With StrComp, you can specify whether the comparison is
[quoted text clipped - 58 lines]
>>>>> MsgBox (TypeName(ActiveCell.Value) = "string") 'Displays 'FALSE'
>>>>> End Sub
Chip Pearson - 12 Oct 2008 16:57 GMT
>The only thing I don't like about using StrComp is it uses 0 for equality.
No argument from me on that score.
Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email is on the web site)
USA Central Daylight Time (-5:00 GMT)
>The only thing I don't like about using StrComp is it uses 0 for equality.
>Of course, I understand why... it makes perfect sense when you consider it
>uses +1 for greater than and -1 for less than... but my mind always equates
>0 with False in logical comparisons and so, when checking for string
>equality, testing StrComp to 0 (a False type value) just seems so wrong to
>me.