+ Reply to Thread
Results 1 to 9 of 9

How to run a delete macro but leave rows based on certain values

  1. #1
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    How to run a delete macro but leave rows based on certain values

    Hi Everyone,

    I'm trying to figure out how to create a macro which would delete all rows except those that have a cell with 0064914800 which is the front part of a UPC code 00649148002059/000.
    That string is common in up to 30 rows up to the point of the last 2 zeros (00649148(00) and are a unique product identifier. These values will always be in column C in Sheet1 with approximately 500 rows. I have attached a sample workbook with the rows we wish to save highlighted in yellow starting at row 275.

    Thank you,
    Dean
    Attached Files Attached Files

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

    Re: How to run a delete macro but leave rows based on certain values

    Try:
    Please Login or Register  to view this content.
    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.

  3. #3
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Re: How to run a delete macro but leave rows based on certain values

    OUTSTANDING Mumps1! Very much appreciated!

    Thanks,
    Dean

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

    Re: How to run a delete macro but leave rows based on certain values

    You are very welcome.

  5. #5
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Re: How to run a delete macro but leave rows based on certain values

    Hey Mumps1,
    I tried running this macro in another workbook and no joy! I'm not seeing in the macro where its referring to a particular workbook or worksheet so I can edit.
    Workbook name is LOTTERY IMPORT and worksheet POS if that makes any difference? Cell range is the same!

    Thanks,
    Dean

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: How to run a delete macro but leave rows based on certain values

    I tried running this macro in another workbook and no joy!
    What does that mean? Does it not do anything? Does it crash and burn? Do you get an error message?

    There's nothing in the macro to restrict it to a specific workbook or sheet.

    Have you copied it into a standard module in an .xlsm/.xlsb macro enabled workbook and enabled macros?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  7. #7
    Forum Contributor
    Join Date
    12-11-2014
    Location
    Missouri
    MS-Off Ver
    2016
    Posts
    153

    Re: How to run a delete macro but leave rows based on certain values

    I'm an idiot! I had it in the wrong order before unprotect Worksheet!
    Thanks for the reply!

    Cheers,
    Dean

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: How to run a delete macro but leave rows based on certain values

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: How to run a delete macro but leave rows based on certain values

    You're welcome. Thanks for the rep.


    I had it in the wrong order before unprotect Worksheet!
    Easy done

+ 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] Macro to delete or leave a value based on criteria of 2 adjacent cells
    By Macca_GB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2019, 02:45 PM
  2. Macro to total values based on vendor criteria, delete rows & continue on
    By Tomtherom in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-16-2015, 04:52 PM
  3. [SOLVED] Help with macro to delete rows based on values
    By jimstrongy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-26-2012, 08:49 AM
  4. Macro needed to delete rows based on values
    By bensun in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-12-2010, 06:23 AM
  5. Delete a rows values but leave formula and conditional formatting
    By BobTheRocker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2010, 03:39 PM
  6. Macro to delete entire rows based values in columns
    By shamade2107 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2009, 11:17 AM
  7. Delete rows with numeric values, leave rows with text
    By GSpline in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-10-2005, 08:05 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