+ Reply to Thread
Results 1 to 9 of 9

Rounding numbers based on IF function

  1. #1
    Registered User
    Join Date
    01-27-2021
    Location
    NL
    MS-Off Ver
    2016
    Posts
    4

    Question Rounding numbers based on IF function

    Hey!

    I am trying to round numbers.

    Basically, if the actual number is 1 digit + decimal places, I want it to use this formula: =MROUND(A1,0.05).

    If the actual number is 2 digits + decimal places, I want it to round down anything that xx.49 and under to the same integer, and anything that is xx.51 and over to the next whole integer.

    I want these two things to be the same formula, is that possible?

    Thanks!
    Attached Files Attached Files
    Last edited by EsorC; 01-27-2021 at 11:36 AM. Reason: Solved!

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,878

    Re: Rounding numbers based on IF function

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    01-27-2021
    Location
    NL
    MS-Off Ver
    2016
    Posts
    4

    Re: Rounding numbers based on IF function

    Thanks! I edited.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Rounding numbers based on IF function

    Basically, if the actual number is 1 digit + decimal places,
    Assuming A1 is always positive (always greater than 0), =IF(A1<10,...,...)
    I want it to use this formula: =MROUND(A1,0.05).
    =IF(A1<10,MROUND(A1,0.05),...)
    I want it to round down anything that xx.49 and under to the same integer, and anything that is xx.51 and over to the next whole integer.
    =IF(A1<10,MROUND(A1,0.05),MROUND(A1,1))

    I notice that your example seems to follow a different logic from what you describe above. Your example shows that you want to round 1.45 up to 1.50 rather than to 1.45. You also show that you want to round 1.64 to 1.60 rather than 1.65. At the same time, you show that you want 5.25 to round to 5.25. There seems to be some inconsistency in your examples. If your examples are correct, we probably need a better explanation of the logic of when to round to x.x5 and when to round to x.x0.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    01-27-2021
    Location
    NL
    MS-Off Ver
    2016
    Posts
    4

    Re: Rounding numbers based on IF function

    Thank you so much!

    I just realized those inconsistencies myself, it was a mistake on my part.

    Edit: I just uploaded the Correct version of my example.
    Attached Files Attached Files
    Last edited by EsorC; 01-27-2021 at 11:35 AM. Reason: Fixing example

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Rounding numbers based on IF function

    Try:

    =mround(a2,if(a2<10,0.05,1))
    Quang PT

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Rounding numbers based on IF function

    Raising question from #4 still remain, for me:

    what is the general logic of:

    1.45=>1.5
    5.25=>5.25

  8. #8
    Registered User
    Join Date
    01-27-2021
    Location
    NL
    MS-Off Ver
    2016
    Posts
    4

    Re: Rounding numbers based on IF function

    Quote Originally Posted by bebo021999 View Post
    Raising question from #4 still remain, for me:

    what is the general logic of:

    1.45=>1.5
    5.25=>5.25
    A mistake on my part, it was supposed to be
    1.45=>1.45
    5.25=>5.25.

    Same as
    1.64=>1.65, not 1.64=>1.60.

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Rounding numbers based on IF function

    So, does my solution in #6 work?

    =MROUND(A2,IF(A2<10,0.05,1))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Rounding Numbers
    By NotMuchCode in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2018, 08:13 AM
  2. Replies: 4
    Last Post: 12-17-2015, 12:33 AM
  3. Rounding Numbers after a cancatenation of two numbers with a hyphen
    By daszlosek in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-24-2015, 12:30 PM
  4. VBA function to STOP rounding numbers
    By evenings in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-12-2010, 02:01 PM
  5. Rounding numbers with CEILING function
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2006, 01:35 PM
  6. [SOLVED] rounding numbers for match function
    By erc_blair in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-14-2006, 11:15 AM
  7. [SOLVED] rounding numbers for match function
    By erc_blair in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-13-2006, 09:25 PM

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