+ Reply to Thread
Results 1 to 26 of 26

Round down last digit to a 3 or 7 whichever comes first

  1. #1
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Question Round down last digit to a 3 or 7 whichever comes first

    Hi All,

    I'm having a round down issue and I keep getting errors.
    The following are just examples, the L17 is the cell with a value which needs to be rounded down.

    If L17 = 5.94 Then M17 needs to round down to 5.93
    If L17 = 5.91 Then M17 needs to round down to 5.87
    If L17 = 5.67 Then M17 needs to remain the same as it ends in a 7
    If L17 = 5.63 Then M17 needs to remain the same as it ends in a 3

    Any help would be greatly appreciated.

    Cheers

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    at first look, try: =IF(A1=5.94,A1-0.01,IF(A1=5.91,A1-0.04,IF(--RIGHT(A1,1)=7,A1,IF(--RIGHT(A1,1)=3,A1,A1)))) (change A1 to L17)

    Or for any value in A1 that ends at 1,3,4,7
    =IF(--RIGHT(A1,1)=4,A1-0.01,IF(--RIGHT(A1,1)=1,A1-0.04,IF(--RIGHT(A1,1)=7,A1,IF(--RIGHT(A1,1)=3,A1,A1))))
    or shorter
    =CHOOSE(IFNA(MATCH(--RIGHT(A1,1),{1,3,4,7},0),4),A1-0.04,A1,A1-0.01,A1)

    there is not too much info about criteria
    Last edited by sandy666; 03-23-2017 at 12:43 AM.

  3. #3
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Re: Round down last digit to a 3 or 7 whichever comes first

    Thanks Sandy I will give that a go.

    I'm not sure what more you would like about the criteria.

    I basically have a column which is a total of a couple of columns, for example L17, this is just a final total so the cell needs to be referenced not the static amount.

    Eg: These are just some examples of what might happen when formula copied & pasted to other cells in Column M)

    Sorry about the underline it's was the only way I could space them out. The formula in this case is in Column (M) referencing Column (L) and then rounding down accordingly when it needs too.

    ______(L)______(M)
    (17)__5.91_____5.87_____(This would round down to the nearest 7 EG: 5.87)
    (18)__5.87_____5.87_____(This would stay on 5.87)
    (19)__5.66_____5.63_____(This would round down to the nearest 3 EG: 5.63)
    (20)__5.43_____5.43_____(This would stay on 5.43)
    (21)__5.29_____5.27_____(This would round down to the nearest 7 EG: 5.27)
    (22)__5.25_____5.23_____(This would round down to the nearest 3 EG: 5.23)

    Is there anything here I've missed with the explanation which I could then help you with please let me know.

    Thanks
    Last edited by StuNet; 03-23-2017 at 01:10 AM.

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    5.91 - 0.04 - 5.87
    5.92 - 0.00 - 5.92
    5.93 - 0.00 - 5.93
    5.94 - 0.01 - 5.93
    5.95 - 0.02 - 5.93
    5.96 - 0.03 - 5.93
    5.97 - 0.00 - 5.97
    5.98 - 0.00 - 5.98
    5.99 - 0.02 - 5.97
    that is ok?
    if yes: =--CHOOSE(IFNA(MATCH(--RIGHT(TEXT(A1,".00"),1),{1,2,3,4,5,6,7,8,9,0},0),10),A1-0.04,A1,A1,A1-0.01,A1-0.02,A1-0.03,A1,A1,A1-0.02,A1)
    (changed because I forgot about : 5.90)
    Variation on the subject:
    =A1---CHOOSE(IFNA(MATCH(--RIGHT(TEXT(A1,".00"),1),{1,2,3,4,5,6,7,8,9,0},0),10),0.04,0,0,0.01,0.02,0.03,0,0,0.02,0)
    btw. hope you've IFNA() on your Mac
    If not - use IFERROR()
    Last edited by sandy666; 03-23-2017 at 04:39 AM.

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Round down last digit to a 3 or 7 whichever comes first

    Or:

    =ROUNDDOWN(A1,1)+LOOKUP(INT(MOD(A1*100,10)),{0,3,7},{-0.03,0.03,0.07})

  6. #6
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    @Phuocam
    check it again

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,141

    Re: Round down last digit to a 3 or 7 whichever comes first

    @Sandy,
    I agree with Phuocam: your values for 5.92 and 5.98 (I think!) should be 5.87 and 5.97.

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    Why? these values are not defined so I assumed they are the same as source

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,141

    Re: Round down last digit to a 3 or 7 whichever comes first

    No ..... because the OP requested data to end in 3 or 7!!!

  10. #10
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    what about post #3 ?

  11. #11
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    5.91 - 0.04 - 5.87
    5.92 - 0.00 - 5.92 - not defined
    5.93 - 0.00 - 5.93
    5.94 - 0.01 - 5.93
    5.95 - 0.02 - 5.93
    5.96 - 0.03 - 5.93
    5.97 - 0.00 - 5.97
    5.98 - 0.00 - 5.98 - not defined
    5.99 - 0.02 - 5.97

    If L17 = 5.94 Then M17 needs to round down to 5.93
    If L17 = 5.91 Then M17 needs to round down to 5.87
    If L17 = 5.67 Then M17 needs to remain the same as it ends in a 7
    If L17 = 5.63 Then M17 needs to remain the same as it ends in a 3
    (17)__5.91_____5.87_____(This would round down to the nearest 7 EG: 5.87)
    (18)__5.87_____5.87_____(This would stay on 5.87)
    (19)__5.66_____5.63_____(This would round down to the nearest 3 EG: 5.63)
    (20)__5.43_____5.43_____(This would stay on 5.43)
    (21)__5.29_____5.27_____(This would round down to the nearest 7 EG: 5.27)
    (22)__5.25_____5.23_____(This would round down to the nearest 3 EG: 5.23)

    so it is not well, it should be changed to 3 and 7 everything except if source = 3 or 7?
    if yes i misunderstood
    Last edited by sandy666; 03-23-2017 at 05:08 AM.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,141

    Re: Round down last digit to a 3 or 7 whichever comes first

    I think it reasonable to assume the 3/7 rule applies to all, given the values ending in 4 and 6 have been adjusted, so "logic" suggests 2 and 8 should be treated in the same way.

  13. #13
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    here is: =A1---CHOOSE(IFNA(MATCH(--RIGHT(TEXT(A1,".00"),1),{1,2,3,4,5,6,7,8,9,0},0),10),0.04,0.05,0,0.01,0.02,0.03,0,0.01,0.02,0.03)
    but i'd like to know from OP
    i am not thinking in en so few errors can be

  14. #14
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Talking Re: Round down last digit to a 3 or 7 whichever comes first

    Thanks for all the responses guys.

    The value to be rounded down from a formula perspective is the cell, eg: L17, L18, L19 etc etc

    With the formula and end result being in the cell M17, M18, M19 etc etc when copied down.

    I put amounts in there to show as stated an example of different numbers and how they would adjust down or if they end with 3 or 7 they remain unchanged.

    I hope this clears it up a little.

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,141

    Re: Round down last digit to a 3 or 7 whichever comes first

    So do you have a solution?

  16. #16
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Re: Round down last digit to a 3 or 7 whichever comes first

    Quote Originally Posted by JohnTopley View Post
    So do you have a solution?
    I wish I did

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,141

    Re: Round down last digit to a 3 or 7 whichever comes first

    What is wrong with those provided?

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  18. #18
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Re: Round down last digit to a 3 or 7 whichever comes first

    Quote Originally Posted by JohnTopley View Post
    What is wrong with those provided?

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Thanks John, I will mock something up if I still can't get this damn thing to work. I have to recheck a couple.

  19. #19
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Re: Round down last digit to a 3 or 7 whichever comes first

    Quote Originally Posted by Phuocam View Post
    Or:

    =ROUNDDOWN(A1,1)+LOOKUP(INT(MOD(A1*100,10)),{0,3,7},{-0.03,0.03,0.07})
    Thanks Phuocam, this is certainly the cleanest way to implement and is getting the desired result except on a couple of cells where the number ending in 7 which should stay on 7 rounds down to a 3. Otherwise the others are working well.

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,141

    Re: Round down last digit to a 3 or 7 whichever comes first

    I tried Phoucam's formula and ending 7 works OK.

    I suspect the issue is the last digit is less than 7 but formatted with 2 digit appears as 7.

    For example: 5.969 (which will appear as 5.97 in cells formatted as number with 2 decimal places) results in value of 5.93 whereas 5.970 results in value of 5.97

  21. #21
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Re: Round down last digit to a 3 or 7 whichever comes first

    Ahhhaaa, John, I suspect you could be onto something here mate.

    I will double check all the formatting to make sure, that's something I didn't consider.

    Cheers for that.

  22. #22
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Round down last digit to a 3 or 7 whichever comes first

    you can try =A1---CHOOSE(IFNA(MATCH(--RIGHT(TEXT(ROUND(A1,2),".00"),1),{1,2,3,4,5,6,7,8,9,0},0),10),0.04,0.05,0,0.01,0.02,0.03,0,0.01,0.02,0.03)
    or adapt ROUND to Phuocam solution

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

    Re: Round down last digit to a 3 or 7 whichever comes first

    This formula should round the actual value as required

    =MAX(FLOOR(A1+{0.03,0.07},0.1)-{0.03,0.07})

    ...but if you really want to base the rounding on how the value looks when rounded to 2 decimal places you can just add a ROUND function to that, I.e.

    =MAX(FLOOR(ROUND(A1,2)+{0.03,0.07},0.1)-{0.03,0.07})
    Audere est facere

  24. #24
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Thumbs up Re: Round down last digit to a 3 or 7 whichever comes first

    Quote Originally Posted by daddylonglegs View Post
    This formula should round the actual value as required


    =MAX(FLOOR(ROUND(A1,2)+{0.03,0.07},0.1)-{0.03,0.07})
    Outstanding daddylonglegs, you rock, that was the final bomb right there, John was spot on earlier as the total of the column which was used to then do the rounding down was created from a formula which multiplied another total by 0.995, as a result even though I could not see it straight away there would have been 3 decimal places in the result hence creating the formula anomaly.

    Now daddylonglegs has come along and made it incredibly lean and restricts it to 2 decimal digits, this is a feature I will use for other things now I reckon as it's so easy to mess up.

    Serious thanks to sandy666, your effort didn't go unnoticed I was just looking for something really lean and clean and optimised, again thank you to Phuocam & John for all your help and advice, really awesome!

    I wish I had a big SOLVED sticker I could plaster across this thread for others to see like that do with real estate, that would be cool for future peeps searching ..

  25. #25
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,141

    Re: Round down last digit to a 3 or 7 whichever comes first

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  26. #26
    Registered User
    Join Date
    03-22-2017
    Location
    Sydney
    MS-Off Ver
    Office for Mac 2011
    Posts
    9

    Re: Round down last digit to a 3 or 7 whichever comes first

    Thanks John, that 'solution' menu is exactly what I needed, appreciate it.

+ 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] Round of 7 digit amount into 2 digit
    By hkbhansali in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-24-2016, 10:34 AM
  2. [SOLVED] LOTTERY FILTER#4, Find if 1 Digit Sum of 2 Digit or 3 Digit, Single Cell w/ dash
    By david gonzalez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2014, 12:57 AM
  3. how to round down last digit
    By ketanco in forum Excel General
    Replies: 2
    Last Post: 06-06-2011, 02:40 AM
  4. How do I round off 7 digit Number in a Cell to Say 4 digits
    By jacksonmathews in forum Excel General
    Replies: 8
    Last Post: 07-19-2007, 01:24 AM
  5. Replies: 0
    Last Post: 06-27-2006, 06:10 PM
  6. round a 15 digit decimal down from .05
    By Excell-ent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2005, 10:06 AM
  7. Replies: 5
    Last Post: 02-19-2005, 07:06 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