+ Reply to Thread
Results 1 to 4 of 4

Insert New Rows based on Number of Deleted Rows

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Insert New Rows based on Number of Deleted Rows

    On the attached example sheet I have some code behind the command button that deletes a row if the cell in column BA of that row contains the "Settled".

    What I want to do is add some more code that inserts new rows at the nd of the current list to replace the ones that have been deleted. As a starting point I've added a COUNTIF formula to BA2 to count how many rows are marked as "settled" then we know how many want replacing (it's not much but it's a start )

    So when you open this workbook, you will see that there are 3 rows settled and pressing the 'delete settled' button will then delete those 3 rows. Therefore 3 new rows (formatted the same as above including formulas) need inserting.

    The normal 'Insert as Above' should work for the formatting, it's getting the code right to know how many want inserting. Then the values/formulas of columns J:M and Q:S want copying down in to these 3 newly formatted row. While column V wants defaulting to No.

    Any help will be much appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Insert New Rows based on Number of Deleted Rows

    Give this a try

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Insert New Rows based on Number of Deleted Rows

    Thanks Mike. It's seems to be almost perfect but I've got a couple of snags at the minute...

    1) When I click the 'delete settled' button it seems to be added 3 new rows regardless of how many have been as 'settled' and deleted.

    2) The formuals in columns J:M and Q:S need copying down in to the newly formatted row.

    Please let me know if anything doesn't make sense.

    Cheers,
    Adam.

  4. #4
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Insert New Rows based on Number of Deleted Rows

    For 'point 1', can we not use the count in cell BA2 and firstly insert the number of rows needed to be replaced and then delete the rows with "Settled" in column BA?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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