+ Reply to Thread
Results 1 to 7 of 7

Deleting multiple rows of specific data

  1. #1
    Registered User
    Join Date
    03-05-2022
    Location
    Florida
    MS-Off Ver
    MS Pro Plus 2019
    Posts
    4

    Deleting multiple rows of specific data

    Hi everyone,

    I need to create a formula that will find and delete entire rows of data in sheet 1 based on the data in sheet 2. The data I want to delete in sheet 1 is identical to what's in sheet 3 but a subset of it. I have about 10000 rows of data to search through so I'd rather not do it one at a time. The formula would read the data in Column C (address) of sheet 2, search for it in sheet 1 and delete that whole row in sheet 1. Thanks in advance for your help!
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Deleting multiple rows of specific data

    Hi and welcome to the forum.
    This was confusing at first since you mentioned Sheet 1 & Sheet 2 but didn't identify which they are.

    However this macro should do what you want

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-05-2022
    Location
    Florida
    MS-Off Ver
    MS Pro Plus 2019
    Posts
    4

    Re: Deleting multiple rows of specific data

    Quote Originally Posted by Richard Buttrey View Post
    Hi and welcome to the forum.
    This was confusing at first since you mentioned Sheet 1 & Sheet 2 but didn't identify which they are.

    However this macro should do what you want
    Sorry it was hard for me to explain it haha. Thank you for taking the time to do this. I tried it but it deleted the data in the second sheet "results" and not the first one "50258 sample"
    I need it to keep the data in the second sheet "results" and delete it from the first sheet "50258 sample"

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Deleting multiple rows of specific data

    This is confusing.

    In your OP your talked of deleting rows in Sheet1. When there is no sheet tab name "Sheet1" nor even a VBA code name Sheet1 then can you see how confusing it can be.

    Your two sheets' tab names are "50258 sample" and "Result" It's reasonable to assume in the absence of you clearly defining sheet 1, that you meant it to be the first shown tab name going left to right, i.e. the "50258 sample" sheet. That sheet has a VBA code name "sample_sheet"

    I interpreted the "Result" sheet is what you want the 50258 sheet to look AFTER the rows have been deleted from the 50258 Sample sheet. It's even more confusing since you mention a Sheet 3 which doesn't exist.

    Hence my VBA code deletes the rows in the 50258 Sample sheet. See the With block of code

    Please Login or Register  to view this content.
    where column G has been added and identifies which values on the 50258 sheet don't exist.

    All that said you appear to be saying that the rows that are currently being deleted should remain and the others remain. In which case just change the first line of code in the With block to

    .Range("G2:G" & lLastRow) = "=IF(MATCH(C2,Result!C:C,FALSE)>0,""Delete"")"

  5. #5
    Registered User
    Join Date
    03-05-2022
    Location
    Florida
    MS-Off Ver
    MS Pro Plus 2019
    Posts
    4

    Re: Deleting multiple rows of specific data

    Quote Originally Posted by Richard Buttrey View Post

    where column G has been added and identifies which values on the 50258 sheet don't exist.

    All that said you appear to be saying that the rows that are currently being deleted should remain and the others remain. In which case just change the first line of code in the With block to

    .Range("G2:G" & lLastRow) = "=IF(MATCH(C2,Result!C:C,FALSE)>0,""Delete"")"
    Now I'm confused too. I created a Loom video that may help. This is my first time working with macros so not even sure if I'm running them correctly. If you want I can Venmo you some money to get this working.

    I can't post the link to my loom video yet.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Deleting multiple rows of specific data

    In the file you have sent none of the 800 addresses in column C on the 50258 Sample sheet exist in the results sheet. Hence there are no records to delete.

    Please update an example workbook which has three sheets.

    Sheet1. A sheet which contains your original data
    Sheet 2 A sheet which shows a subset of the SHeet 1 Data
    Sheet 3 What you expect Sheet 1 to look like after the relevant records have been deleted.

  7. #7
    Registered User
    Join Date
    03-05-2022
    Location
    Florida
    MS-Off Ver
    MS Pro Plus 2019
    Posts
    4

    Re: Deleting multiple rows of specific data

    Here it is. I picked a continuous set of rows (100-119) but in reality the addresses would be spread out throughout Sheet1.
    Attached Files Attached Files

+ 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] Deleting rows with no data even if there is a header with specific rows and sheets
    By glide2131 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-19-2022, 12:25 PM
  2. [SOLVED] Deleting rows with specific data
    By JerBear in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-13-2013, 02:14 PM
  3. Macro for Deleting Specific Rows of Data
    By maliotta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2013, 04:16 PM
  4. [SOLVED] VBA code for deleting Rows that contain specific criteria from Filtered Data
    By carlosriver24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2012, 12:23 PM
  5. [SOLVED] Deleting multiple rows with specific criteria in multple columns
    By cb10 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 10:16 AM
  6. Deleting Rows Based on Specific Data
    By Jakz34 in forum Excel General
    Replies: 1
    Last Post: 04-12-2011, 09:00 PM
  7. Deleting rows based on data in a specific cell
    By minimimerr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2010, 06:10 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