+ Reply to Thread
Results 1 to 9 of 9

Splitting A number into four differnet cells

  1. #1
    Registered User
    Join Date
    04-21-2007
    Posts
    12

    Splitting A number into four differnet cells

    I need to split a number into 4 different cells, depending on what the number is.
    If the number 165,735 were entered, I would need the four cells to show:
    Cell 1 = 1
    Cell 2 = 6
    Cell 3 = 57
    Cell 4 = 35
    In short, it takes 100 in Cell 4 to make 1 in Cell 3. 100 in Cell 3 would make 1 in cell 2, etc...

    I have no idea how to go about doing this. Thanks for any help you can give.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Everquest,

    The logic escapes me. At first it looked like you were doing Modulus 100 math, but no. Can you further explain this odd separation's rules?

    Sincerely,
    Leith Ross

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475
    Quote Originally Posted by Everquest
    I need to split a number into 4 different cells, depending on what the number is.
    If the number 165,735 were entered, I would need the four cells to show:
    Cell 1 = 1
    Cell 2 = 6
    Cell 3 = 57
    Cell 4 = 35
    In short, it takes 100 in Cell 4 to make 1 in Cell 3. 100 in Cell 3 would make 1 in cell 2, etc...

    I have no idea how to go about doing this. Thanks for any help you can give.
    I suppose you could use text to columns, this is just a recroded macro

    Please Login or Register  to view this content.
    if the value is always 6 digits then you could use something like this

    =LEFT(A1,1)
    =MID(A1,2,1)
    =MID(A1,3,2)
    =RIGHT(A1,2)

  4. #4
    Registered User
    Join Date
    03-08-2007
    Location
    Brisbane, Australia
    Posts
    57
    To use formula, with 165735 keyed to A1:

    Please Login or Register  to view this content.
    Assumes your number is a whole number no higher than 999,999

  5. #5
    Registered User
    Join Date
    04-21-2007
    Posts
    12
    I just realized that I messed up my original post. The number 165,735 would fall into these cells:
    Cell 1 = 0
    Cell 2 = 16
    Cell 3 = 57
    Cell 4 = 35

    The number 1,165,735 would fall into:
    Cell 1 = 1
    Cell 2 = 16
    Cell 3 = 57
    Cell 4 = 35

    The number will go no higher than 999,999,999

    100 of Cell 4 = 1 of Cell 3. 10,000 of Cell 4 = one of Cell 2. 1,000,000 of Cell 4 = one of Cell 1.

    Thanks for all your help on this; I'm really sorry that I posted the numbering wrong.

  6. #6
    Registered User
    Join Date
    03-08-2007
    Location
    Brisbane, Australia
    Posts
    57
    Thanks for providing the upper limit. What would be in Cell1 if 999,999,999 was keyed?? Are all cells to hold a maximum of two digits?? or can Cell1 hold 3? If 2, how does the 999mill get laid out??

    James

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    To me, it looks like you're simply taking the rightmost two digits and inserting them in the 4th cell, then the next two rightmost digits into the 3rd cell, the next two into the 2nd cell, and the last two into the first cell (if they exist).

    It doesn't look like any math or logic is involved. Plus, based on your example (and as Red questioned), your 4 cells cannot handle a number over 99,999,999 (not 999,999,999 as you suggest). If it goes from 100 to 10,000 to 1,000,000 then the next step would be 100,000,000 - requiring a 5th cell that could handle numbers up to 9,999,999,999.

    If I'm on the right track.. let's say your four cells are A1, A2, A3, A4, and your number is in cell B1, then use these formulas in A1 through A4 (in order):

    A1 =IF(LEN(B1)<7,"",RIGHT(LEFT(B1,LEN(B1)-6),2))
    A2 =IF(LEN(B1)<5,"",RIGHT(LEFT(B1,LEN(B1)-4),2))
    A3 =IF(LEN(B1)<3,"",RIGHT(LEFT(B1,LEN(B1)-2),2))
    A4 =RIGHT(B1,2)

  8. #8
    Registered User
    Join Date
    03-08-2007
    Location
    Brisbane, Australia
    Posts
    57

    Math

    Not arguing with PJ's method, . . . .
    but it can be done with a degree of logic/math, as suggested originally by Leith.

    See the attached file, especially Sample 4. Sample 5 takes it one step further, introducing Base10 exponential, which allows you to specify how many digits should appear in the cells (assuming same number of digits in each cell).

    James

    Split Numbers.zip

  9. #9
    Registered User
    Join Date
    04-21-2007
    Posts
    12
    You guys are right; I was being dumb yet again. 99,999,999 would be the max number. The examples worked great! Thanks a lot.

+ 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