+ Reply to Thread
Results 1 to 14 of 14

Insert Rows by number of Dropdown

  1. #1
    Registered User
    Join Date
    12-06-2018
    Location
    Hamburg, Germany
    MS-Off Ver
    2016
    Posts
    7

    Insert Rows by number of Dropdown

    Hello Guys

    I hope you can help me. First i don`t know a lot about VBA and all Makros i used so far have been just recorded ones.

    Currently I´m trying to create an Excelfile, where i can choose a specific number from a dropdown menu (that´salready done) and I want, that one row is then copied and inserted into the file as often as the number says.
    For example:
    I choose "3" in the dropdown in cell B2 and then row 1 from sheet 2 is inserted 3 times into the sheet below row 11.

    Till now I didn´t find any Solution which i understood and were able to adjust to my needs.

    So I hope you will be able to help me.

    Thanks
    Manuel

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Insert Rows by number of Dropdown

    Is row 11 the first available blank row in the sheet? In other words, do you want the rows to be copied to the first available blank row each time you select a number form the drop down?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    12-06-2018
    Location
    Hamburg, Germany
    MS-Off Ver
    2016
    Posts
    7

    Re: Insert Rows by number of Dropdown

    Yes it´s the first available blank. But the row need to be inserted, as below are the final results of all the formulas.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Insert Rows by number of Dropdown

    Can you attach a copy of your file. It would make it easier to test possible solutions. De-sensitize the data if necessary.

  5. #5
    Registered User
    Join Date
    12-06-2018
    Location
    Hamburg, Germany
    MS-Off Ver
    2016
    Posts
    7

    Post Re: Insert Rows by number of Dropdown

    So in the file in B2:B8 is the dropdown. I want that when i for example choose 3 in B2 and 6 in B4, that row 1 from "tabelle3" is inserted 3 times and row 5 from "tabelle3" is inserted 6 times at the position of row 14.

    I hope it´s understandable :D
    Attached Files Attached Files

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Insert Rows by number of Dropdown

    How do you determine which row to copy from "tabelle3"? Will you always copy row 1 if you make a selection in B2 and always copy row 5 if you make a selection in B4? Also, do you always want to insert at row 14? Please clarify. It would help if you could manually insert the rows in the Rechner sheet to show what the results would look like. Perhaps you can attach an updated file.
    Last edited by Mumps1; 12-06-2018 at 12:12 PM.

  7. #7
    Registered User
    Join Date
    12-06-2018
    Location
    Hamburg, Germany
    MS-Off Ver
    2016
    Posts
    7

    Re: Insert Rows by number of Dropdown

    Yes it will be always row 1 for selection in B2, row 2 for selection in B3, row 3 for B4, ... So B2:B8 is related to rows 1-7 in "tabelle3" (as they´re named A-G). Means when i choose like in the attached example, the shown rows are inserted. So 3 times A, 1 times C and 2 times D. Actually the inserted rows are all the same, except of the name in column A. There the names are different. Probably this makes it easier.

    Thanks a lot for your help. I really appreciate that.
    Attached Files Attached Files

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Insert Rows by number of Dropdown

    Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your "Rechner" sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make a selection in B2:B8. The macro assumes that there will always be some data in the green merged cells that currently contain the word "Results".
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-06-2018
    Location
    Hamburg, Germany
    MS-Off Ver
    2016
    Posts
    7

    Re: Insert Rows by number of Dropdown

    Thanks a lot. That works perfect. Is there also a way to reduce the rows in case i choose a lower number after i for example misclicked?

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Insert Rows by number of Dropdown

    You are very welcome. Perhaps the easiest way would be to highlight the rows and delete them manually.

  11. #11
    Registered User
    Join Date
    12-06-2018
    Location
    Hamburg, Germany
    MS-Off Ver
    2016
    Posts
    7

    Re: Insert Rows by number of Dropdown

    Yes thats how I do it But i also get error 1004 when switching back to 0.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Insert Rows by number of Dropdown

    Try this macro. When you select zero it will delete the rows.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-06-2018
    Location
    Hamburg, Germany
    MS-Off Ver
    2016
    Posts
    7

    Re: Insert Rows by number of Dropdown

    Works perfect now. Thank you so much

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Insert Rows by number of Dropdown

    My pleasure.

+ 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: 7
    Last Post: 10-14-2016, 05:33 PM
  2. Replies: 2
    Last Post: 09-11-2016, 12:40 PM
  3. Replies: 2
    Last Post: 09-11-2016, 12:39 PM
  4. Replies: 1
    Last Post: 09-11-2016, 12:39 PM
  5. [SOLVED] Macro to insert specific number of rows, populate rows with data above except date
    By Melissa Camp in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-08-2015, 03:59 PM
  6. [SOLVED] insert a number in sheet1, add that number of rows in sheet2 and sheet3
    By dishguy05 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-07-2014, 04:55 PM
  7. [SOLVED] VBA insert/delete rows to accommodate exact number of rows from incoming data
    By iloc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2012, 06:19 PM

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