Number variable loses format on write
Maybe it was the mixture of variables. You could post your code (AND THE
NUMBERS USED) if you want.
Halray wrote:
I had the varibale declared as: Dim AreaSum as double, so I'm confused as to
why one declaration works and the other doesn't. Do you think it has
anything to do with re-declarating (probably not the correct wording) the
variable and reassigning it the value just before writing it?
Thanks again for taking the time to look at my issue.
--
Ray
"Dave Peterson" wrote:
The # sign means that the variable is declared as a double.
Dim Area_Summed as Double
would have the same effect.
Halray wrote:
Dave,
Thanks for trying to help. The fix was to use a variable declared with the
pound symbol on the end. I'm not sure why that symbol matters, but it
worked. I did the following:
With ActiveWorkbook.Worksheets("Dump Area")
.Cells(RowNumber, 3) = RetentionTime
area_summed# = AreaSum
.Cells(RowNumber, 2) = area_summed#
'output paraffin area counts to column-4
area# = AreaCounts
.Cells(RowNumber, 4) = area#
End With
--
Ray
"Dave Peterson" wrote:
None from me.
But you never said what the numbers were!
Halray wrote:
Dave,
I've been away, but now that I check what you say I do not have that option
checked. Any more ideas?
--
Ray
"Dave Peterson" wrote:
One more guess.
If the cell is formatted to show 2 decimals and you have
Tools|Options|calculation tab|precision as displayed checked, it could cause
what you describe.
With ActiveCell
.NumberFormat = "0.00"
.Value = "1234.1234"
MsgBox .Value
End With
Halray wrote:
Two decimal places are displayed in the formula bar. In the debugger the
varibale has four decimal places.
--
Ray
"Dave Peterson" wrote:
If you look in the formulabar, do you see all 4 decimals?
If yes, try widening the column.
If no, what value do you see in the debugger and what value do you see in the
formulabar?
Halray wrote:
Have have a varibale declared as a double, read a number into it from a file.
THe variable is indicated with four decimal places when viewed in the
debugger. When I write the variable out to Excel using the following the
number gets truncated to two decimal places:
With ActiveWorkbook.Worksheets("Dump Area")
.Cells(RowNumber, 2) = AreaCounts
Anyone have any suggestions to fix this problem?
Thanks !
--
Ray
--
Dave Peterson
--
Dave Peterson
--
Dave Peterson
--
Dave Peterson
--
Dave Peterson
|