+ Reply to Thread
Results 1 to 8 of 8

Insert numbers of based upon difference of two numbers

  1. #1
    Registered User
    Join Date
    01-31-2012
    Location
    ottawa,wi
    MS-Off Ver
    Excel 2010
    Posts
    12

    Insert numbers of based upon difference of two numbers

    hi- thank you to anyone who replies in advance.. but I have a file with a min in column P and a max in column R. Is it possible to write a code that would calc the difference between the two numbers and copy&insert those amount of rows.

    ex:

    row1 info1 info2 info3 7 10 info4
    row2 info5 info6 info7 10 12 info5

    goal:

    row1 info1 info2 info3 7 14 info4
    row2 info1 info2 info3 7 14 info4
    row3 info1 info2 info3 7 14 info4
    row4 info5 info6 info7 10 12 info5
    row5 info5 info6 info7 10 12 info5

  2. #2
    Registered User
    Join Date
    01-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Re: help: need macro to insert numbers of based based upon difference of two numbers

    Im not sure if i follow you

    lets say if you have the number 7 in column "p" and 10 in column "R" you want it to insert 3 rows and copy the data from the row you were working with?

    If so will you do this with every row or just one by one?

  3. #3
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: help: need macro to insert numbers of based based upon difference of two numbers

    look at attachment and try to adjust this code to your conditions
    Attached Files Attached Files
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  4. #4
    Registered User
    Join Date
    01-31-2012
    Location
    ottawa,wi
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: help: need macro to insert numbers of based based upon difference of two numbers

    hi wieli, yes- that is correct. so, from my very confusing example above, i would essentially want the first row copied (and inserted) three times ( 10-7) and then the second row down (10-12) would be copied and inserted 2 times... so after the macro is ran "row2"...would become the fourth row down.

    i am sorry.. i see my goal got messed up. it should have stayed at
    row1 info1 info2 info3 7 10 info4
    row2 info1 info2 info3 7 10 info4
    row3 info1 info2 info3 7 10 info4

  5. #5
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: help: need macro to insert numbers of based based upon difference of two numbers

    Ok change my code for this one and try to adjust
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-31-2012
    Location
    ottawa,wi
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: help: need macro to insert numbers of based based upon difference of two numbers

    sample file ex.xlsxthak you, i am attaching the sample file. basically, i have labeled the sections- original- after macro to copy and insert rows based on DIFF colum- the goal result. So I want to the Ages columns to be sequential from the min to the max ages for each CODE.

    thank you sooooo much!!!
    Last edited by excellentlearner; 02-08-2012 at 03:01 PM.

  7. #7
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: help: need macro to insert numbers of based based upon difference of two numbers

    This is not speed's deamon but works (I hope)

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-31-2012
    Location
    ottawa,wi
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: help: need macro to insert numbers of based based upon difference of two numbers

    awesome! works perfectly!!! thank you Tom!

+ 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