ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF - case sensitive argument (https://www.excelbanter.com/excel-programming/321332-udf-case-sensitive-argument.html)

Ed

UDF - case sensitive argument
 
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!)


JulieD

UDF - case sensitive argument
 
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

"ed" wrote in message
...
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!)




JE McGimpsey

UDF - case sensitive argument
 
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.


In article ,
"ed" wrote:

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!)



All times are GMT +1. The time now is 12:23 PM.

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