Excel Macro Using "Like" comparison

  • Thread starter Thread starter jswalsh33
  • Start date Start date
J

jswalsh33

I have found it convenient to use a macro code such as - If Cells(x, 3) Like
SS = True Then Check = "True"- where SS is - SS = Range("E12") & "*".

I find that this comparison is case sensitive, which is inconvenient for my
purposes. Is there a way of making this process insensitive to case with this
macro code or some other code?

Jim Walsh
 
Make the comparison in the same case like this:

If LCase(Cells(x, 3).Value) Like "ss = true" Then Check = "True"
- where SS is - SS = Range("E12") & "*"
 
jswalsh33 said:
I have found it convenient to use a macro code such as - If Cells(x, 3) Like
SS = True Then Check = "True"- where SS is - SS = Range("E12") & "*".

I find that this comparison is case sensitive, which is inconvenient for my
purposes. Is there a way of making this process insensitive to case with this
macro code or some other code?

Jim Walsh
 
Disregard the last one, I hit post in error.


JLGWhiz said:
Make the comparison in the same case like this:

If LCase(Cells(x, 3).Value) Like "ss = true" Then Check = "True"
- where SS is - SS = Range("E12") & "*"
 
You can also use the "Option Compare" statement at the top of the module
to force a case-insensitive comparison: Option Compare Text
--
Jim Cone
Portland, Oregon USA



"jswalsh33" <[email protected]>
wrote in message
I have found it convenient to use a macro code such as - If Cells(x, 3) Like
SS = True Then Check = "True"- where SS is - SS = Range("E12") & "*".

I find that this comparison is case sensitive, which is inconvenient for my
purposes. Is there a way of making this process insensitive to case with this
macro code or some other code?
Jim Walsh
 
I don't follow your example, but in general I like converting to upper case
for case insensitive comparison.

If UCase(s1) Like UCase(s2) Then...
 
Back
Top