ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compare Strings Question (https://www.excelbanter.com/excel-programming/354250-compare-strings-question.html)

Sabo, Eric

Compare Strings Question
 
I have the following:

If current = temp then

End if


My problem is the following:

Current = Apple
temp = APPLE

How can I compare these two strings without the case involved. I want the
if statement to treat them as equal.

Thank,
Eric Sabo




Norman Jones

Compare Strings Question
 
Hi Eric,

Try:

If LCase(current) = LCase(temp) then


---
Regards,
Norman



"Sabo, Eric" wrote in message
...
I have the following:

If current = temp then

End if


My problem is the following:

Current = Apple
temp = APPLE

How can I compare these two strings without the case involved. I want
the if statement to treat them as equal.

Thank,
Eric Sabo





Tim

Compare Strings Question
 
Hi Eric I think this should work

If StrComp(temp, Current, vbTextCompare) = 0 Then

'Your Code in here

End If

regards,

Tim


Tim

Compare Strings Question
 
Hi Eric I think this should work

If StrComp(temp, Current, vbTextCompare) = 0 Then

'Your Code in here

End If

regards,

Tim


Tom Ogilvy

Compare Strings Question
 
if strcomp(Current,Temp,1) = 0 then


or

if ucase(Current) = Ucase(Temp) then

--
Regards,
Tom Ogilvy


"Sabo, Eric" wrote in message
...
I have the following:

If current = temp then

End if


My problem is the following:

Current = Apple
temp = APPLE

How can I compare these two strings without the case involved. I want

the
if statement to treat them as equal.

Thank,
Eric Sabo






Dave Peterson

Compare Strings Question
 
There's a setting that you can use that makes text comparisons case insensitive.

Add
Option Compare Text
Right at the top of the module--outside any procedure.

Then you can just compa

if current = temp then

If case never matters for any procedure in that module, it's an easy fix.


"Sabo, Eric" wrote:

I have the following:

If current = temp then

End if

My problem is the following:

Current = Apple
temp = APPLE

How can I compare these two strings without the case involved. I want the
if statement to treat them as equal.

Thank,
Eric Sabo


--

Dave Peterson


All times are GMT +1. The time now is 03:40 PM.

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