+ Reply to Thread
Results 1 to 6 of 6

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

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Kelowna, England
    MS-Off Ver
    Excel 2011
    Posts
    4

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

    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)

    Please Login or Register  to view this content.
    Last edited by Cutter; 10-28-2012 at 12:42 PM. Reason: Added code tags

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

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

    Hi, [email protected],

    this macro will take ages to run maybe you should have a look at Find which would speed up the duration according to what I think.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

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

    I have a huge database list of customers
    Have you tried using auto filter?

    Alf

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

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

    @ [email protected]

    Welcome to the forum.

    Please notice that [CODE] tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.

  5. #5
    Registered User
    Join Date
    10-27-2012
    Location
    Kelowna, England
    MS-Off Ver
    Excel 2011
    Posts
    4

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

    Sorry about that Cutter will remember from now on! Thanks for your replies guys. Alf yeah i have used auto filter but i needed something to remove it entirely not just hide it with a filter.

    HaHobe thank you very much for your code it worked really nicely but yeah it was super slow and the data base is pretty big. no idea where i found it now but i played around a little and endedup with this code and it works!! will post it incase anyone else in the future may need it!


    Sub MassUnsubscribe()
    Dim EndRw As Long
    On Error Resume Next
    EndRw = Worksheets("Customer List").Range("E65536").End(xlUp).Row
    For RowTester = EndRw To 1 Step -1

    If Application.WorksheetFunction.Match(Worksheets("Customer List").Range("E" & RowTester).Value, Worksheets("Unsubscribe Tab").Range("E:E"), 0) > 0 Then
    If Err.Number > 0 Then
    Err.Clear
    GoTo NextRow
    Else
    Worksheets("Customer List").Rows(RowTester).Delete
    End If
    End If
    NextRow:

    Next RowTester
    End Sub


    Thanks again guys!

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

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

    @ [email protected]

    Alf yeah i have used auto filter but i needed something to remove it entirely not just hide it with a filter.
    Filter to get the rows you don't need then you delete these.

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1