+ Reply to Thread
Results 1 to 7 of 7

Rounding to Multiples WITH IF's

  1. #1
    Registered User
    Join Date
    04-20-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Rounding to Multiples WITH IF's

    I'm trying to write a formula using a combination of the MROUND and IF functions. I can't get it to work. Basically here's the scenario: I've got a formula that's already working to calculate into a cell (for example: B4). I plan on hiding that column (hypothetically B) of cells and put this MROUND formula into, say, H4.

    Ultimately, I want H4 to take the results of the formula in B4 and round them the nearest multiple...

    BUT there are conditions.... Different "multiples" depending on how large the number is:

    Round to 3's - if the result is 1 to 18
    Round to 6's - if the result is 19 to 36
    Round to 12's - if the result is greater than 37

    I also need to add an "IF" statement to the effect that if the result in B4 is "0" that H4 will reflect a hyphen only "-" rather than a zero.

    Any help would be appreciated! Thank you

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Rounding to Multiples WITH IF's

    Try:

    =IF(B4=0,"-",MROUND(B4,LOOKUP(B4,{1,19,37},{3,6,12})))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    04-20-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Rounding to Multiples WITH IF's

    It works great, but i'm running into problems with #N/A popping up.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Rounding to Multiples WITH IF's

    Can you give examples?

  5. #5
    Registered User
    Join Date
    04-20-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Rounding to Multiples WITH IF's

    27 87 0 0 0 30 96 #N/A #N/A #N/A
    36 111 0 0 0 36 120 #N/A #N/A #N/A
    27 87 0 0 0 30 96 #N/A #N/A #N/A

    The black numbers are those that are "rounding" the corresponding number in pink. In each line the 1st number in pink corresponds with the 1st number in black. As you can see, "#N/A" pops up for the zeros which I find to be very bizarre, since this worked fine yesterday. Only when i opened the spreadsheet this morning did this happen.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Rounding to Multiples WITH IF's

    Could those 0's be actually something between 0 and 1 (i.e. decimal value, like 0.00001)?

    If so you can try either rounding in the formula like:

    =IF(ROUND(A1,0)=0,"-",MROUND(A1,LOOKUP(A1,{1,19,37},{3,6,12})))

    or changing the first Lookup array value to 0...

    =IF(A1=0,"-",MROUND(A1,LOOKUP(A1,{0,19,37},{3,6,12})))

  7. #7
    Registered User
    Join Date
    04-20-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Rounding to Multiples WITH IF's

    That is 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