+ Reply to Thread
Results 1 to 10 of 10

create a range from two value macro

  1. #1
    Registered User
    Join Date
    06-09-2009
    Location
    CAlifornia
    MS-Off Ver
    Excel 2003
    Posts
    9

    create a range from two value macro

    Ok im trying to have excel create a rage of numbers from the given values in cells b1and b2. I would like to add 11 to b1 till the last digit is 6 then add 4 to only that number then continue to add 11 till the last digit is a 6 then add 4 again then back to adding 11 and so on till the value in b2 is reached I have attached my file for an example in addition to the below.

    When given the values of 60862620 and 60862922 once 60862686 is reached then 4 would need to be added then after that 11 would need to be added till another number ends with 6 then 4 is added. EXAMPLE:

    60862620 +11
    60862631 +11
    60862642 +11
    60862653 +11
    60862664 +11
    60862675 +11
    60862686 +4
    60862690 +11
    60862701 +11
    60862712 +11
    60862723 +11
    60862734 +11
    60862745 +11
    60862756 +4
    Attached Files Attached Files
    Last edited by skimura; 12-02-2010 at 12:15 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: create a range from two value macro

    Try this in E2
    Please Login or Register  to view this content.

    Is that what you mean?

    Or is this the correct formula
    Please Login or Register  to view this content.

    Your data appears to conflict with your description
    Last edited by Marcol; 12-01-2010 at 04:24 PM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Registered User
    Join Date
    06-09-2009
    Location
    CAlifornia
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: create a range from two value macro

    Quote Originally Posted by Marcol View Post
    Try this in E2
    Please Login or Register  to view this content.

    Is that what you mean?

    Or is this the correct formula
    Please Login or Register  to view this content.

    Your data appears to conflict with your description
    this does not seem to keep the sequence. Basically i just need it to add 11 to the start number then and keep adding 11 till it reaches a number ending in 6 then add 4 to only that number then add 11 till it reaches another number ending in 6 then add 4 again and so on till the end number is reached.

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: create a range from two value macro

    I think you want:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: create a range from two value macro

    The problem seems to be, that in Post#1 you ask to add 4 when the last digit is 6, but in your sample workbook you seem to want to add 6 when the last digit is 6

    You then, perhaps by accident, provide a pattern that repeats, every 7 rows (6 @ +11, then 1 @ +4 (or +6))

    I think we need some better explanation of your rules

    @ Cutter your formula and my second suggestion return the same result provided that we know if it is to be C2+4 or C2+6


  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: create a range from two value macro

    Marcol

    Yep, I realize that. Just providing an alternative (based solely on his samples in OP, I didn't look at his file and, therefore, didn't see discrepancies).

    From his OP it wasn't even clear if he wanted VBA for this but I assumed not when he tried your solution and couldn't get it to work.

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: create a range from two value macro

    Now, after looking at the sample file I would suggest this formula in C3 copied down as far as is necessary:

    Please Login or Register  to view this content.
    if 4 is to be used for numbers ending in 6. Otherwise change the "C2+4" part to "C2+6" or whatever other number you want.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: create a range from two value macro

    No problem Cutter just wish at times a little more thought could be applied before questions are asked, sometimes the old way, dare I say paper and pencil, might be advantageous.

    It was the last line in the sample
    60862763 +6
    That made me think a series might be involved

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: create a range from two value macro

    There are actually 2 lines in the sample showing +6 but I assume the error in thinking is the 6 because he was thinking of the last digit being a 6 as a trigger.

    In any event I'll offer an amended formula:

    Please Login or Register  to view this content.
    just to cover any errors.

  10. #10
    Registered User
    Join Date
    06-09-2009
    Location
    CAlifornia
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: create a range from two value macro

    Quote Originally Posted by Cutter View Post
    There are actually 2 lines in the sample showing +6 but I assume the error in thinking is the 6 because he was thinking of the last digit being a 6 as a trigger.

    In any event I'll offer an amended formula:

    Please Login or Register  to view this content.
    just to cover any errors.

    Sorry my mistake Yes i mistyped i need 4 added not six sorry for the confusion. But I thank you all for the work on this cause it works great thank you!!!

+ 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