+ Reply to Thread
Results 1 to 4 of 4

Delete rows based on cell value

  1. #1
    Registered User
    Join Date
    06-26-2015
    Location
    Poland
    MS-Off Ver
    365
    Posts
    56

    Delete rows based on cell value

    Hey,
    I'm in need of macro which could do the following:
    1. With active sheet, check what is the value in cell (If .Cells(6, "U").Value = [number] in my case),
    2. If value is 28 then check in column "O" for numbers 29, 30 and 31 and delete entire rows,
    3. If value is 29 then delete rows with 30 and 31,
    4. If value is 30 then delete rows with 31,
    5. If value is 31 do nothing, abort the macro.
    There will never be lesser value than 28 and greater than 31.
    Any help is greatly appreciated!
    Last edited by Pojzon; 05-05-2018 at 01:39 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Delete rows based on cell value

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    06-26-2015
    Location
    Poland
    MS-Off Ver
    365
    Posts
    56

    Re: Delete rows based on cell value

    Thank you very much. Works great, but I was wondering if there is any way to make it work faster other than Application.ScreenUpdating = False/True? With 7000 rows it can take ~30s, it's not much, but I'm just thinking.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Delete rows based on cell value

    You could probably use autofilter combined with SpecialCells instead of the For ... Next loop on the last two tests of U6 value. Might be a little quicker for those two conditions. But you still have test the cell holding the value that defines what to look for in column O.

+ 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] BEST way to delete rows based on cell value
    By EchoPassenger in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-22-2017, 01:51 PM
  2. [SOLVED] delete rows based on cell value
    By shakir1401 in forum Excel - New Users/Basics
    Replies: 9
    Last Post: 12-21-2015, 10:22 AM
  3. Delete rows based on the value of a cell
    By Emma_B in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-04-2013, 05:35 PM
  4. Delete certain rows based on value in another cell
    By angelk in forum Excel General
    Replies: 1
    Last Post: 07-30-2012, 02:38 PM
  5. Merging MonthView & DTPicker Valuie into one cell
    By adam2308 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-01-2009, 06:41 PM
  6. Delete Rows based on cell value and then Insert rows alternatively with a formula
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-11-2008, 04:27 PM
  7. Delete rows based on Cell name
    By gmunro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2005, 09:15 AM

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