+ Reply to Thread
Results 1 to 5 of 5

Rounding numbers to specific integers

  1. #1
    Registered User
    Join Date
    11-05-2006
    Posts
    14

    Rounding numbers to specific integers

    Hey, I was wondering if anyone could help me out on this problem. I'm trying to round off my numbers to specific integers. Sorta like a step function (in algebraic terms).

    For example, my first few intgers are 0-8-13. I want: 0<=X<8, 8<=X<13, etc.

    So far, this is what I have:

    =IF(C2>=0,IF(C2>=8,IF(C2>=13, IF(C2>=20, IF(C2>=35, IF(C2>=55, IF(C2>=85, IF(C2>=125, "blank", 85), 55), 35), 20), 13), 8 ),0 ), "blank2")
    It seems to work perfectly to there. However, when I try and enter the next set, an error pops up. This is what didn't work:

    =IF(C2>=0,IF(C2>=8,IF(C2>=13, IF(C2>=20, IF(C2>=35, IF(C2>=55, IF(C2>=85, IF(C2>=125, IF(C2>=200, "blank", 125), 85), 55), 35), 20), 13), 8 ),0 ), "blank2")
    The bold being the new things that I added.

    *C2 is where the raw data is inputted

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    What is the purpose of what you are trying to do. Are you saying that you want to round any random number to 0, 8, or 13? ie if I were to select 9, it would round to 8. If I select 11, it would round to 13? Is this what you want?

    Matt

  3. #3
    Registered User
    Join Date
    11-05-2006
    Posts
    14
    I want all numbers 8<=X<13, <=13<20, etc. So all numbers greater than 8 but less than 13.

    So using your example, if you chose 9 it would turn to 8. if you choose 11 it would also be 8 since the next round able integer is 13, and 11<13.

  4. #4
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Try this in cell C3

    =CHOOSE(MATCH(C2,{0,8,13},1),0,8,13)

    EDIT: Better still, try this =LOOKUP(C2,{0,8,13})

    Matt

  5. #5
    Registered User
    Join Date
    11-05-2006
    Posts
    14
    Wow. Thank you very much. I've never known about any of those functions you just mentioned :P

    I tried both, they work perfectly. 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