If currency data type is storing 4 digits, why it always have 2 digit when writing to a cell?

Jamualson

Board Regular
Joined
Feb 17, 2021
Messages
145
Office Version
  1. 2019
Platform
  1. Windows
When using the CCur function: it doesn't matter how many digits a number has, it will always write only 2 digits into the cell. (In immediate window it would print 4 digits)

What can be the cause? Thank you very much

VBA Code:
Sub test()

Cells(1, 1).Value = CCur(50.5678956789)     '50,57
 
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
What is at least the current cell format ?​
 
Upvote 0
It's a quirk of the Value property when assigning a currency value (it doesn't happen when reading one) - I've never seen it documented anywhere though. Use Value2 instead if you need to avoid that.
 
Upvote 0
Solution
It's a quirk of the Value property when assigning a currency value (it doesn't happen when reading one) - I've never seen it documented anywhere though. Use Value2 instead if you need to avoid that.
Thank you, but then I loose currency type and result can be inexact, I am wrong?
 
Upvote 0
I don't believe you would lose accuracy. You'll just need to format the cell with a currency format for it to be a currency value.
 
Upvote 0
I don't believe you would lose accuracy. You'll just need to format the cell with a currency format for it to be a currency value.
Yes, sorry, i mean i can not get more than 2 decimals if i write back currency to worksheet. (with value2 i can write back more decimals but it will be double)
 
Upvote 0
It’s only a currency value if the cell is formatted accordingly.
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,927
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top