ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   comparing name (https://www.excelbanter.com/excel-programming/424373-comparing-name.html)

Abhinandan

comparing name
 
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


Chip Pearson

comparing name
 

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)


On Thu, 19 Feb 2009 08:38:07 -0800, Abhinandan
wrote:

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


Abhinandan

comparing name
 
Hi this worked.
Thanks very much
Abhinandan

"Chip Pearson" wrote:


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)


On Thu, 19 Feb 2009 08:38:07 -0800, Abhinandan
wrote:

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




All times are GMT +1. The time now is 01:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com