+ Reply to Thread
Results 1 to 9 of 9

Help needed deleting specific rows.

Hybrid View

  1. #1
    Registered User
    Join Date
    07-16-2020
    Location
    Dallas, Texas
    MS-Off Ver
    2019
    Posts
    4

    Smile Help needed deleting specific rows.

    Hello there,

    We are working on a research project pertaining to the Covid-19 virus. We need to curate a long list of anti-viral agents down to a manageable list. We have removed a few antiviral agents and would like to remove some more. List 1 (titled Worksheet 1 in the attached file) is what I would like to retain, it contains about 23,000 different anti-viral agents. The rest of the anti-viral agents have to be deleted from the bigger list ( list 2 titled Worksheet 2 in the attached file) containing roughly 30,000 anti-viral agents. Both of these lists have been entered in 2 different worksheets. List 2 contains the anti-viral agents from list 1 but it contains 7,000 additional anti-viral agents that I wont be needing. Hope the question is clear. There are around 30,000 rows so deleting the rows manually is not feasible. Is there any add-in or built-in Microsoft Excel feature that will let me delete the rows automatically.

    Thank you for your time and consideration.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by thesmallfry123; 07-18-2020 at 02:07 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Help needed deleting specific rows.

    Select the top row of the data and select Data=>Filter, drop-down arrows will appear on the top row.

    Click the arrow and select what you want to filter for. Lots of options and custom filters as well

    Worth the practise.


    dataFilter.jpg

  3. #3
    Registered User
    Join Date
    07-16-2020
    Location
    Dallas, Texas
    MS-Off Ver
    2019
    Posts
    4

    Re: Help needed deleting specific rows.

    Thank you for getting back to me. One thing I should have mentioned earlier is that, the list I would like to retain (worksheet 1) contains about 23,000 different anti-viral agents. The rest of the anti-viral agents have to be deleted from the bigger list containing roughly 30,000 anti-viral agents(Worksheet 2). List 2 contains the anti-viral agents from list 1 but it contains 7,000 additional anti-viral agents that I wont be needing. Hope the question is clear.

  4. #4
    Forum Contributor
    Join Date
    03-18-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    251

    Re: Help needed deleting specific rows.

    Hi, if you can attached a file and stated what you desire to get for your final reports, and I think this can be done using Power Query.
    Christopher Yap

  5. #5
    Registered User
    Join Date
    07-16-2020
    Location
    Dallas, Texas
    MS-Off Ver
    2019
    Posts
    4

    Re: Help needed deleting specific rows.

    I have attached the excel file. List 1 (titled Worksheet 1 in the attached file) is what I would like to retain, it contains about 23,000 different anti-viral agents. The rest of the anti-viral agents have to be deleted from the bigger list ( list 2 titled Worksheet 2 in the attached file) containing roughly 30,000 anti-viral agents. Both of these lists have been entered in 2 different worksheets. List 2 contains the anti-viral agents from list 1 but it contains 7,000 additional anti-viral agents that I wont be needing. Hope the question is clear. There are around 30,000 rows so deleting the rows manually is not feasible.
    Thank you once again.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    03-18-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    251

    Re: Help needed deleting specific rows.

    Hi,

    Bring in Worksheet1 and Worksheet2 to Power Query Editor, Merge both of them as New, filter those not in Worksheet1, load to excel in Final worksheet

    If this is what you want and a simple way
    Attached Files Attached Files

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,037

    Re: Help needed deleting specific rows.

    Try:
    Sub CompareLists()
        Application.ScreenUpdating = False
        Dim rng As Range, RngList As Object, WS1 As Worksheet, WS2 As Worksheet, LastRow As Long, x As Long
        Set WS1 = Sheets("worksheet 1")
        Set WS2 = Sheets("worksheet 2")
        LastRow = WS2.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        Set RngList = CreateObject("Scripting.Dictionary")
        For Each rng In WS1.Range("A2", WS1.Range("A" & WS1.Rows.Count).End(xlUp))
            If Not RngList.Exists(rng.Value) Then
                RngList.Add rng.Value, Nothing
            End If
        Next
        For x = LastRow To 2 Step -1
            With WS2
                If Not RngList.Exists(.Cells(x, 1).Value) Then
                    .Rows(x).Delete
                End If
            End With
        Next
        Application.ScreenUpdating = True
    End Sub
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: Help needed deleting specific rows.

    This will undoubtedly require VBA, so I've taken the liberty of moving your thread to the VBA section.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  9. #9
    Registered User
    Join Date
    07-16-2020
    Location
    Dallas, Texas
    MS-Off Ver
    2019
    Posts
    4

    Re: Help needed deleting specific rows.

    thank you all for the help. I have managed to perform the task successfully. Thanks once again for the prompt aid.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel VBA HELP needed! Capturing Adding and Deleting of Rows on spreadsheet.
    By nex2022 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2014, 12:01 PM
  2. Urgent Help Needed! - Deleting rows by multiple conditions
    By shivboy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-01-2014, 04:54 AM
  3. Merging Rows with multiple selections without deleting text, VBA may be needed
    By carlc711 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2013, 11:41 AM
  4. Deleting rows if specific cell is blank or have specific text
    By JoaoFerreira1985 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2013, 01:18 PM
  5. Auto Move Rows macro is deleting needed data
    By jessica.betando in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2013, 09:20 PM
  6. Comapring two excel worksheets and adding or deleting rows as needed
    By dmreno in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 01-31-2012, 08:55 AM
  7. Adding and Deleting rows - update formulas help needed.
    By bperks in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-31-2006, 03:35 PM

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