Matching email address and deleting row, don't want it to be case sensitive

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
721
Office Version
  1. 2016
Platform
  1. Windows
I have this little script that works well, unless it encounters an email address that isn't exactly a match.

As an example, if I had john.doe@email.com on sheet1 and john.DOE@email.com on sheet0, the row john.DOE@email.com is on would not be deleted.

How can I get around that?

VBA Code:
Sub delete()
    
    Dim x As Long, z As Long, lr0 As Long, lr1 As Long
    Dim wss As Sheets
    Dim ws0 As Worksheet, ws1 As Worksheet
    
    Set wss = ThisWorkbook.Worksheets
    Set ws0 = wss("Sheet0")
    Set ws1 = wss("Sheet1")
    
    lr0 = ws1.Cells(Rows.Count, 1).End(xlUp).Row
    lr1 = ws2.Cells(Rows.Count, 1).End(xlUp).Row
    
    For x = lr0 To 1 Step -1
        For z = 1 To lr1
            With ws0
                If .Range("C" & x) = ws1.Range("A" & z) Then .Rows(x).delete
            End With
        Next z
    Next x

End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You can use wrap your values being tested with UCase or LCase eg UCase(.Range("C" & x).Value)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

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