Forum Discussion

JuJuBee's avatar
JuJuBee
Copper Contributor
Jun 22, 2026
Solved

Rounding Issues

I am trying to create a "change maker" spreadsheet.  We have a need to determine monetary denominations for several clients for refunds...

 

ABCDEFGHIJKL
RandomMoney1005010510.250.100.050.01 
775.1047775.10712100100$775.10 
949.3219949.32904141012$949.32 
947.3099947.31904121010$947.30 
1231.751231.751203013000$1,231.75 
1180.48361180.481113001202$1,180.47 
1486.39011486.391413111104$1,486.39 
59.16659.17010140112$59.17 
1450.54181450.541410002003$1,450.53 
1042.67261042.671004022112$1,042.67 
88.900488.90013133110$88.90 
457.3006457.30410121010$457.30 

The formulas:

A: ROUND(RAND()*(1500-30)+30,4) - random number generator to create random money amounts between $30 & $1500

B: ROUND(A3,2) - round A to 2 decimal places for money

C2: INT(B3/$C$2) - Calculate $100's (simple)

C3: =INT(($B3-(SUMPRODUCT(ROUND($C$2:C$2,2),ROUND($C3:C$3,2))))/D$2) - Calculate each other denomination - requires keeping track of current balance..

D3:K3 - Similar to C3 adjusting for col/row...

D3-K3 are same as D2 adjusted for col/row...

L3: ($C$2*C3)+($D$2*D3)+($E$2*E3)+($F$2*F3)+($G$2*G3)+($H$2*H3)+($I$2*I3)+($J$2*J3)+($K$2*K3) - Error Checking...

 

The problem is in the Pennies column.  Sometimes it is off by $0.01 as in rows 4, 6, & 9

 

A secondary problem that I am having is copying formulas with $...  Sometimes when I copy a formula down that has ROUND($C3:H$3,2) for example, the H$3 turns into H3 and the $ is removed.  In other cases it is added where it didn't exist.  Is this normal behavior?  I thought the $ was there to fix the row/col reference?

 

MK

  • Hi JuJuBee​,

    Try below formula in cell D2 (drag it right and down).

    =INT(ROUND(($B2 - (SUMPRODUCT(ROUND($C$1:C$1, 2), ROUND($C2:C2, 2)))), 2) / D$1)

    or more shorter:

    =INT(ROUND(($B2 - (SUMPRODUCT($C$1:C$1, $C2:C2))), 2) / D$1)

    HTH

    IlirU

2 Replies

  • m_tarler's avatar
    m_tarler
    Silver Contributor

    The problem is only in the last column for the penny.  Replace INT with ROUND( ... ,0)

    So column K should be:

    =ROUND(($B3-(SUMPRODUCT($C$2:J$2,$C3:J3)))/K$2,0)

    As for the problem with the $ is the you have $C3:H$3 which is technically locking row 3 and column C and when you copy down you would get $C4:H$3, which although you can type it that way, it is still C3:H4 and therefore Excel will correct it to $C$3:H4

    Finally you can also do this using array formulas like:

    A3 with =RANDARRAY(10,1,30,1500,0)

    B3: =ROUND(A3#,2)

    C3: =INT(B3#/C2)

    D3: =INT(($B3#-MMULT($C3#:C3#,TRANSPOSE($C$2:C$2)))/D$2)

    and then just copy to the right (but again change the INT to ROUND in column K

    Alternatively you can use LAMBDA and LAMBDA helpers like MAP or BYROW to generate the entire table of values 

     

    EDIT: I like IlirU​ suggestion to use the INT(ROUND( .... , 2) / D$2).  I like this because although the problem is only being experienced when you get to the penny level, I think in theory it could happen at other levels because if you get a round off error that after division results in X.999999 then INT will return X instead of X+1, which is the problem you were seeing.   

     

  • IlirU's avatar
    IlirU
    Iron Contributor

    Hi JuJuBee​,

    Try below formula in cell D2 (drag it right and down).

    =INT(ROUND(($B2 - (SUMPRODUCT(ROUND($C$1:C$1, 2), ROUND($C2:C2, 2)))), 2) / D$1)

    or more shorter:

    =INT(ROUND(($B2 - (SUMPRODUCT($C$1:C$1, $C2:C2))), 2) / D$1)

    HTH

    IlirU