UDF - case sensitive argument

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is my issue:
For example, ‘txt’ is coming from a cell in a worksheet entered by the user.

Function Test(txt as string) as string
If (txt = "comm. lse" Or txt = "ME") Then
Do this
Else
Do that
End If
End Function

If the user enters Comm Lse, the statement will “Do that†instead of “Do
thisâ€. Any suggestions? (drop downs are not welcomed by the users...yet!)
 
Hi Ed

if you want a case insesitive function you can do something along the
following lines

Function Test(txt As String) As String
If (LCase(txt) = "comm. lse" Or UCase(txt) = "ME") Then
Do this
Else
Do that
End If
End Function

Cheers
JulieD
 
If you're just worried about case:

Public Function Test(txt As String) As String
If (LCase(txt) = "comm. lse" Or UCase(txt) = "ME") Then
'Do this
Else
'Do that
End If
End Function

note that this will not catch the lack of a "." in your example.
 

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