Member_2_6479049
asked on
How to hold currency without rounded in VBA
Hello experts,
I made a report in VBA where I need to hold money but the result always is rounded, for example:
If the source data is 528.85 , the report shows 529.
Could you please help me in this matter?
I made a report in VBA where I need to hold money but the result always is rounded, for example:
If the source data is 528.85 , the report shows 529.
Could you please help me in this matter?
Dim cAcumulaCheques As String
Dim cAcumulaMonto As String
Dim nMonto As Integer
Dim nMontoCurrency As Currency
Dim nSumaTotalMonto As Currency
For I = 3 To wsSource.Cells(Rows.Count, "A").End(xlUp).Row
If wsSource.Cells(I, 4).Value = "" Then
GoTo Nexts
Else
If Val(wsSource.Cells(I, 1)) = Val(nDia) And Val(wsSource.Cells(I, 2)) = Val(nMes) And Val(wsSource.Cells(I, 3)) = Val(nAno) Then
If Trim(wsSource.Cells(I, 15) <> "") Then
cAcumulaCheques = Trim(wsSource.Cells(I, 15))
nMonto = CInt(wsSource.Cells(I, 16))
nMontoCurrency = Format(nMonto, "Currency")
cAcumulaMonto = nMontoCurrency
nSumaTotalMonto = (nSumaTotalMonto + nMonto)
End If
ASKER
But doesn't work
the nMontoCurrency must have 68.76 but displays 69
the nMontoCurrency must have 68.76 but displays 69
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Gustav,
You right, I alredy fix it.
:)
You right, I alredy fix it.
:)
nMonto = CInt(wsSource.Cells(I, 16))
nMontoCurrency = Format(nMonto, "Currency")
so that's why.
/gustav