View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
okaizawa okaizawa is offline
external usenet poster
 
Posts: 129
Default Number variable loses format on write

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?


TypeName function returns the type of a variable.
check your variable like this:

Dim AreaCounts As Double
MsgBox TypeName(AreaCounts)

'your code

MsgBox TypeName(AreaCounts)
.Cells(RowNumber, 2) = AreaCounts

I wonder if you have overlooked a typo or a mistake like
"Dim AreaCounts, AreaSum As Double", and then the Variant variable
has a Currency value.

--
HTH,

okaizawa