Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50079

Macro to removed entire row on Sheet A if a text matches a condition on Sheet B

$
0
0
Hi all! first post after searching the internet for 3 days!!!
I have a huge database list of customers on Sheet A (first name,last name, address,emai,etc...) and another list on Sheet B.

I need a macro that will search through the emails in column E on Sheet B and remove the whole roll if a match is found on Sheet A.
There will be multiple emails in column E sheet B and each would need to remove a the matching email&row on sheet A.

I have a code that runs and works but it is only for a single specific value in sheet B for example (E1) where i need it to search through the whole E column and find all the matches!

Thank you so much to anyone who can help i've had sleepless nights over this i feel like im so close yet so far!!
I know very little about code so please use layman's terms :/

Andy

(My Code)

'Sheet A is Customer list (column E contains emails)
'Sheet B is Unsubscribed Customers (E again contains email address)

Sub Unsubscribe1()

Dim DatRng As Range
Sheets("Customer List").Select
lastrow = Cells(Rows.Count, "E").End(xlUp).Row
Set DatRng = Range("E1:E" & lastrow)
For Each Cell In DatRng
If Cell.Value = Sheets("Unsubscribed Customers").Range("E2") Then
Cell.EntireRow.Delete
End If
Next Cell
Sheets("Unsubscribed Customers").Select

End Sub

Viewing all articles
Browse latest Browse all 50079

Trending Articles