+ Reply to Thread
Results 1 to 6 of 6

Insert New Rows to Table based on cell value

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

    Insert New Rows to Table based on cell value

    On the attached example, I would like to click the command button and the code would insert the number of rows specified by cell BA2 to the next blank row (13 in this case). I then need the code to copy down the formulas and values of columns J:M in these 3 new rows in the table.Then the same in columns Q:S.

    I have added a second worksheet (After) to show how I expect the first worksheet (Before) to look after running the code. Hope this helps to explain.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Insert New Rows to Table based on cell value

    You could use this macro:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Insert New Rows to Table based on cell value

    hi adam2308, you could do that without VB at all, please check attachment

    You data has been converted to a data table. In order to get values in L, R, S columns you need to input them as a formula. So instead 43% you need to input it =43% etc. Try to add entries manually or copy additional data below.
    Attached Files Attached Files

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

    Re: Insert New Rows to Table based on cell value

    Thanks Antonio, your code seems to work perfectly. I now need to add the second part to the code where I delete those rows marked as "Settled" after I have inserted my new rows.

    I previously had this code to do that job
    Please Login or Register  to view this content.
    and I was hoping I could now piece the bits of code together but I'm having no joy. Can this be done?

    Many thanks,
    Adam.

  5. #5
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Insert New Rows to Table based on cell value

    I'm sorry to answer so late but unfortunately I don't have setted notification for replies.

    You could use this new code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

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

    Re: Insert New Rows to Table based on cell value

    Thanks Antonio. This is much closer but there was one small piece to fix. When the macro inserts the new rows then it needs to format these new rows the same as the the last one in the table. Currently all the columns are not formatted the same as above with validation drop-downs and date formats etc.

    I may have mis-guided you a little on this when the example I posted in the original post had the next 3 rows (13-15) already formatted as above for some reason when in reality these rows will not be formatted. So, you may want to delete these rows before running the macro then you can see my problem.

    Hopefully it's just a case of instructing the macro to 'format as above' when inserting the new rows?

    Thanks again.

+ 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