+ Reply to Thread
Results 1 to 16 of 16

Delete rows on multiple sheets if cell contains specific criteria.

  1. #1
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Delete rows on multiple sheets if cell contains specific criteria.

    Hi All,

    I've been having a problem trying to write some code to delete rows on multiple worksheets. I basically have 5 sheets out of 8 in a workbook where I would like all rows that contain either 'Booked' or 'Not booked' in column G to be deleted. Each worksheet has a different number of rows however it will always be column G that contains the criteria.

    I'm sure they may be a simple way around this, could anyone help?

    Thanks!

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    HI John,

    Thanks! It seems to work on the first sheet by deleting the rows with 'Booked' in them. However how simple would it be to add another criteria to delete those with 'Not booked' too. Also for the other sheets (column g cells are blank at the moment) it just deletes the headings row at the top and leaves the rest of the data.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Hi John, thanks again but this time around the code doesn't seem to work at all

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Can you provide a sample file with some dummy data, where it doesn't work on?

  7. #7
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Sure, I've attached a dummy version where in this case I want only data with booked or not booked in column G of the first 3 sheets to be deleted.

    Thanks!
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    This seems too work on your sample.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    This works perfectly however there is a slight problem, if column G contains nothing on the sheet than it will simply delete the headings row. For example if one of the sheets does not have a 'booked' or 'not booked' cell in column G... the headings row will be deleted. Not quite sure why this is the case. Thanks again!

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Try this:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Same situation again, is there a way to put some code in that will ignore the row if it is a blank and move onto the next? Issue only seems to come up if the cell is blank and this may be the case in mt spreadsheet.

    Thanks!

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Ok, maybe:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    Thanks, this one works perfectly now. I have one more question if that's ok... I would like to assign this macro to a button on a dashboard at the front of the workbook. However this stops the macro from working (It only works if I run it from the first of the pages I would like rows deleted from. Any simple way to do this?

  14. #14
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    It shouldn't?

    You need to change the Sheet names within the Array to reflect the Sheets you want it to run on.

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    08-06-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    You're right it shouldn't have been. Closed the workbook and opened it again and it seemed to work fine. Thanks again!

  16. #16
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows on multiple sheets if cell contains specific criteria.

    You're welcome. Glad to help out and thanks for the feedback. Please mark this thread as SOLVED.

+ 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. Delete Rows with specific criteria
    By love2waltz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2015, 11:59 AM
  2. delete entire rows based on cell value in multiple sheets
    By forquaidian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2014, 05:31 AM
  3. [SOLVED] Delete Row if Cell Contains Specific Values (Multiple Criteria)
    By efarkouh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-01-2014, 11:38 AM
  4. [SOLVED] How to delete rows with specific value for multiple sheets
    By cnj_zeng in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-14-2012, 04:29 PM
  5. Replies: 1
    Last Post: 07-29-2011, 05:03 AM
  6. Delete multiple rows of data based on criteria in a single cell
    By slaga9 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2011, 03:41 AM
  7. Delete Rows if value in cell does not equal desired value ACROSS multiple sheets
    By nature47 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2009, 02:00 AM

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