comparing name

  • Thread starter Thread starter Abhinandan
  • Start date Start date
A

Abhinandan

Sub test()

Dim name As String

name = InputBox("Please write your name below")

If name = "xyz" Then
MsgBox "matches"
Else
MsgBox "does not match"
End If

End Sub

Hi,

In the above progarm, when I type xyz in the input box, the name matches.
However, when I type XYZ, the name does not match. Irrespctive of whether I
type XYZ or xyz, the name should match. Can please someone point me in the
right direction.

Thanks,
Abhi
 
Try

If StrComp(Name, "xyz", vbTextCompare) = 0 Then
' match
Else
' no match
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Hi this worked.
Thanks very much
Abhinandan

Chip Pearson said:
Try

If StrComp(Name, "xyz", vbTextCompare) = 0 Then
' match
Else
' no match
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Back
Top