Modify Macro to not be case sensitive

dougebowl

Board Regular
Joined
Feb 22, 2010
Messages
60
I have this Macro that works great. Problem I am now noticing is that it is case sensitive. So, CAT vs. cat is showing as "No Match". This Macro has worked for what I needed it to do, but, now have the need for it to not be case sensitive. I need it to show CAT vs. cat is a Match and not a No Match. Can someone please provide how to not make it case sensitive. I appreciate all the support from this Forum.

Sub Compare()
Dim Rng As Range, Dn As Range, Sp As Variant, S As Variant
Dim Txt1 As String, Txt2 As String
Dim i As Long
Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))

For Each Dn In Rng
Txt1 = Replace(Dn.Value, " ", "")
Txt2 = Replace(Dn.Offset(, 1).Value, " ", "")
Sp = Split(Txt1, ";")
For i = LBound(Sp) To UBound(Sp)
If Not InStr(Txt2, Trim(Sp(i))) > 0 Then
Dn.Offset(, 2) = "No Match"

Exit For

End If
Dn.Offset(, 2) = "Match"

Next
Next Dn
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
How about
VBA Code:
If Not InStr(1, Txt2, Trim(Sp(i)), vbTextCompare) > 0 Then
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top