+ Reply to Thread
Results 1 to 6 of 6

insert an x number of rows according to data in a cell

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    27

    insert an x number of rows according to data in a cell

    Hello,

    iam not sure if this is possible or not but maby someone her knows,

    i want a macro that can enters a number of rows according to the number in a cell

    so for example if row A4 has "(4x)" (or just "4" i can get it to only a number that doesn't matther for me)

    it should copy that entire row and insert it 3 times (so i end up with 4)

    the number will always be in the same colloumn, the amound of rows etnered will always be diffrent and sometimes there won't be a number in the cell.

    i don't really know if this is possible but i know i certainly won't be able to do this


    atm iam doing it with this macro
    Please Login or Register  to view this content.
    this code will also number the rows that have been entered, if you can use this it would be nice

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: insert an x number of rows according to data in a cell

    Hoimae,

    Do you need to loop through all of the numbers in a column? If so, try the following code

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-16-2012
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: insert an x number of rows according to data in a cell

    it did work when i first tried it but now it doesn't anymore, but how do i specify what colloumn i want it to use?

    Edit: it does indeed work, for colloumn A, but i can't find where i can change that, and it should start from row 16, agian no cleu where to change that.. also iam already using "i" in the macro i posted above, can i just change it to anyting i like?
    Last edited by hoimae; 08-21-2012 at 05:53 AM.

  4. #4
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: insert an x number of rows according to data in a cell

    Hoimae,

    Sure, you can change the i to a different letter (just make sure to change it through the entire iteration of the code.

    To change the code to start with Row 16, make this change to the opening of the For Loop line:
    Please Login or Register  to view this content.
    The 16 in this case refers to the first row that it queries.

    You also need the code to work on a different column. You need the following amendments (I'm assuming you need column C, change it as needed):
    Please Login or Register  to view this content.
    Then
    Please Login or Register  to view this content.
    In the Cells() function, the first number is the row number, and the second is the column number. So, A = 1, B = 2, C = 3, etc.

    Let me know of any questions.

  5. #5
    Registered User
    Join Date
    08-16-2012
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: insert an x number of rows according to data in a cell

    This works great! thanx for that. But while we're at it, there is 1 thing that would be nice. Is it hard to add -1, -2 enz to the rows that have been entered? i mean like this:
    Please Login or Register  to view this content.
    the problem with above code is that it takes my selection, wich i can't use in the last code. Again i don't know if its possible it would save me quite some time:D

    Edit: for this colloumn A will always be nummer 1 2 3 enz till end so only the rows that will be coppied will have the same number multiple times, maby that helps.
    Last edited by hoimae; 08-22-2012 at 05:07 AM.

  6. #6
    Registered User
    Join Date
    08-16-2012
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: insert an x number of rows according to data in a cell

    bump, anyone?

+ 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