+ Reply to Thread
Results 1 to 11 of 11

Breaking up a number

  1. #1
    Registered User
    Join Date
    01-04-2010
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Arrow Breaking up a number

    Hi,

    I have a question which is taxing my head.

    I have a number in one cell which is between 1 and 15 inclusive, and I want to break which ever number is chosen into the sum of 1,2,4 and 8, with each digit displayed in a separate cell. In the remainder cells if any are blank I would like 0 (zero) to be displayed

    e.g.

    15 ----> Cell 1 = 1, Cell 2 = 2, Cell 3 = 4, Cell 4 = 8

    or

    9 -----> Cell 1 = 1, Cell 2 = 0, Cell 3 = 0, Cell 4 = 8

    Using the numbers 1,2,4 and 8 there is only one way to sum each of the numbers 1-15 inclusive. The results of the 4 cells I'm using an if statement to display an "x" next to an option.

    Not to sure on the best way to do this, any ideas?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Breaking up a number

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then start a new thread in one of the question forums -- this isn't one.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-04-2010
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Breaking up a number

    Sorry, do you want me to repost, or can you move the thread?

    Rgds

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Breaking up a number

    I can't move the thread (not a Mod), so can you repost in the Worksheet Functions forum?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Breaking up a number

    thread moved.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Breaking up a number

    It's not clear where the values are etc but if given use of XL2007 if you have say 1,2,4,8 listed in B1:E1 and the value of interest (eg 15 or 9 etc...) in A2 then

    EDIT: revised

    Please Login or Register  to view this content.
    is that what you want ?
    Last edited by DonkeyOte; 01-04-2010 at 12:30 PM.

  7. #7
    Registered User
    Join Date
    01-04-2010
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Breaking up a number

    No sorry, not if I'm using it correctly.

    If I know the answer is 9, I would like to excel to produce the digits in seperate cells of the sum. i.e. I could put the answer "9" in A1 and excel would show A2 "1" B2 "0" C2 "0" D2 "8"

    or if "15" is put in A1 excel would show A2 "1" B2 "2" C2 "4" D2 "8"

    Does that make sense?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Breaking up a number

    It does, and DO's suggestion does that:
    Please Login or Register  to view this content.
    And alternative, in B2 and copied across and down:

    =B$1 * MID(DEC2BIN($A2, 4), 5 - COLUMNS($B2:B2), 1)

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Breaking up a number

    If you need to generate the values without headers then if A1 holds 9

    Please Login or Register  to view this content.
    edit:

    or to use shg's more succinct version simply modify along same lines as above re: use of 2^ multiplier, ie:

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 01-04-2010 at 12:46 PM.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Breaking up a number

    You could avoid DEC2BIN with this version.....

    Number in A2 then this formula in B2 copied across as far as you need

    =(MOD($A2,2^COLUMNS($B2:B2))>=2^COLUMNS($B2:B2)/2)*(2^COLUMNS($B2:B2)/2)

  11. #11
    Registered User
    Join Date
    01-04-2010
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Breaking up a number

    Cheers, copied it wrong!! Works a treat! Many Thanks!!!

+ 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