View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] tamarack007@gmail.com is offline
external usenet poster
 
Posts: 1
Default VBA code outputs currency value rounded to 2 decimal points

Hello,

I have a macro which calculates the value of a currency variable and
then using the statement
ActiveCell.Offset(-1,7).Value = currTradeValue outputs it to a
spreadsheet.

The value is always rounded to 2 decimal points despite trying the
following;

1. I have checked the value of the variable prior to the above
statement being executed and it is as I expect - 3 decimal points e.g.
-1.125

2. Formatted the target cell using
ActiveCell.Offset(-1,7).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
prior to the assignment statement.

3. Manually formatted the cell within Excel prior to the assignment
statement.

4. Checked the Online Help.

If I have a cell that contains a 4 decimal point number for example
and format the cell to round to 2 decimal points, and then select that
cell, the number in the formula bar is the original 4 decimal point
number.

For some reason, the value of the currency variable seems to be
modifed to 2 decimal points before being output as it is the modified
value that I see in the formula bar when the cell in question is
selected.

Could someone please tell me what I or Excel is doing wrong.

Thank you
Mark.