+ Reply to Thread
Results 1 to 4 of 4

Delete Rows Based on the Entry in Another Cell

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Delete Rows Based on the Entry in Another Cell

    I have a workbook which has a hidden worksheet named 'Template'. There is some code that creates new worksheets based on criteria in the Summary worksheet, so if you run the macro called CreateSheets, it will create new worksheets for every code which has a 'Complete' status on the Summary sheet, putting the relevant code in cell C5 on the newly created sheets and giving the worksheet the same name as the code.

    On these newly created sheets are some SUMIFS formula to sum values (see very simplified sample attached). The values in cells E10:E19 (always the same range) change based on the entry in cell C5 and this results in the values in some cells in E10:E19 being zero.

    What I want to happen is that when the new worksheets are generated any rows in the range E10:E19 on each newly created sheet that show zero are automatically deleted. So on the attached sample:

    on sheet AB123, rows 10, 13, 15 and 19 would be deleted
    on sheet XZ689 rows 11, 14, 15, 18 and 19 would be deleted
    on sheet PQ792 rows 13, 14, 16, 17 and 18 would be deleted and so on for each sheet

    Is there a way to achieve this by adding to the code?

    The code to generate the new worksheets, kindly created by skywriter is:

    Please Login or Register  to view this content.
    Many thanks
    Thanks,
    HangMan

    You can say "Thank you!" by clicking Add Reputation below the post.
    Please, mark your thread [SOLVED] if you are happy with the solution.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Delete Rows Based on the Entry in Another Cell

    Hello Hangman,

    See if this works :
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Delete Rows Based on the Entry in Another Cell

    Hi GC Excel,

    Many thanks, that seems to be working a treat...

    If I also has a second range on each sheet where I want to do the same thing, is it simply a case of repeating this part of the code?

    Please Login or Register  to view this content.
    so say e.g. I also need to delete rows with zero values in column G on rows 30 to 50 could I just add

    Please Login or Register  to view this content.
    or would I need to set up another variable, e.g. Dim k As Integer and add this?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Delete Rows Based on the Entry in Another Cell

    Hello HangMan,

    If you add this, you can use the same variable :
    Please Login or Register  to view this content.
    Or even, like this :
    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 06-25-2015, 07:29 AM
  2. Replies: 2
    Last Post: 01-12-2015, 02:27 AM
  3. copy and paste excel rows based on cell entry
    By camileigh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-16-2013, 12:05 PM
  4. macro to copy multiple rows based on cell entry
    By uncleslinky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2011, 07:23 AM
  5. 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
  6. [SOLVED] Delete rows based on a cell value in the row
    By Dave in forum Excel General
    Replies: 7
    Last Post: 03-14-2006, 02:50 PM
  7. Moving rows of data based on a YES cell entry
    By Karrie in forum Excel General
    Replies: 3
    Last Post: 01-19-2005, 10:34 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