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

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
723
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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,215,372
Messages
6,124,537
Members
449,169
Latest member
mm424

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