+ Reply to Thread
Results 1 to 5 of 5

Getting an Integer Number that is part of a precise sum

Hybrid View

  1. #1
    Registered User
    Join Date
    11-20-2014
    Location
    rome
    MS-Off Ver
    Office 2010
    Posts
    5

    Getting an Integer Number that is part of a precise sum

    Hello everyone,

    I'm experiecing a difficulty with excel that probably is very easy to solve for any of you.
    I've tried to search for answers but i didn't find the right solution to my problem.

    I'm applying some complicate formulas in a column that are returning a number.
    The formula is the same for each cell. These cells are summed in a final cell.

    I would like to have in each cell an integer that can be exactly summed with the others in the last cell, not a number with decimals.

    For example, if the sum is 10 and i have summed 5 cells, i would like to have 5 in the first, 2 in the second, 3 in the third and in the last 2 0.
    At the moment, when the sum is 10 i have 3.2 in the first, 2.5 in the second etc.

    Round function is not helping cause it just formats the number, it doesn't transform it in a true integer.

    Thank you in advance,

    Albertz

  2. #2
    Registered User
    Join Date
    02-21-2014
    Location
    Connecticut, U.S.A.
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Getting an Integer Number that is part of a precise sum

    Instead of using the Round function, why not try using Int function instead? Maybe you can post your workbook?

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Getting an Integer Number that is part of a precise sum

    Hi, welcome to the forum

    Round function is not helping cause it just formats the number, it doesn't transform it in a true integer.
    Not so, round physically changes the cell contents, not the formatting.

    The table blow shows the affect of ROUND() using different decimals, all cells are formatted to 4 decimal places to show the difference

    A
    B
    C
    D
    E
    F
    1
    Round 0 Round 1 Round 2 Round 3 Round 4
    2
    1.1
    1.0000
    1.1000
    1.1000
    1.1000
    1.1000
    3
    2.22
    2.0000
    2.2000
    2.2200
    2.2200
    2.2200
    4
    3.333
    3.0000
    3.3000
    3.3300
    3.3330
    3.3330
    5
    4.4444
    4.0000
    4.4000
    4.4400
    4.4440
    4.4444
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    11-20-2014
    Location
    rome
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Getting an Integer Number that is part of a precise sum

    Quote Originally Posted by FDibbins View Post
    Hi, welcome to the forum



    Not so, round physically changes the cell contents, not the formatting.

    The table blow shows the affect of ROUND() using different decimals, all cells are formatted to 4 decimal places to show the difference

    A
    B
    C
    D
    E
    F
    1
    Round 0 Round 1 Round 2 Round 3 Round 4
    2
    1.1
    1.0000
    1.1000
    1.1000
    1.1000
    1.1000
    3
    2.22
    2.0000
    2.2000
    2.2200
    2.2200
    2.2200
    4
    3.333
    3.0000
    3.3000
    3.3300
    3.3330
    3.3330
    5
    4.4444
    4.0000
    4.4000
    4.4400
    4.4440
    4.4444
    Hi Ford,

    thank you for your answer.
    Yes, you're right. Round gives me an integer. However, i still need that the sum of those integers is exactly the one i have already.

    I cannot post the workbook cause it is work related stuff.
    Thank you for helping.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,380

    Re: Getting an Integer Number that is part of a precise sum

    I expect that you are dealing with rounding error introduced by the ROUND() function. See if this scenario describes your problem:

    5 values: 1.25, 1.25, 1.25, 3.125, 3.125 Sum = 10.000
    round each value to the nearest integer and sum:
    5 values: 1,1,1,3,3 Sum =9.0000 This is because each incidence of the ROUND function rounded down. Other scenarios could be envisioned where the round then sum process rounds up more than it rounds down and you get a larger sum.

    I am not sure what "the right" way is to correct this kind of situation. One approach I tend to use (because it tends to be appropriate for the work I do) looks like this:

    Round the first four values: 1,1,1,3
    fifth value =desired total - sum of these four --- 10-sum(1,1,1,3)=4

    The main concern I see is that there is not a unique way to do this. If I enter the numbers in a different order, I might get 3+3+1+1+2=10 rather than 1+1+1+3+4=10. Are these two solutions equivalent?

    Is that even remotely correct, or am I way off?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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 formula, Need only integer part
    By elunicotomas in forum Excel General
    Replies: 4
    Last Post: 10-29-2014, 11:43 AM
  2. Check if the last part of entered string is an Integer
    By szpt9m in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-08-2014, 11:08 PM
  3. Can I use a defined integer as part of a shape name
    By newatmacros in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-23-2010, 05:12 PM
  4. Count the number of occurrences of an integer withing a larger integer
    By nnktran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2010, 01:04 PM
  5. how do I convert an integer to hh:mm (part II)
    By kdell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2006, 05:40 PM

Tags for this Thread

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