Small Decimal Won't Copy
I already have a workaround, but would like to understand why this was a problem (Excel 2007):
I have VBA code that is supposed to copy a row of numeric values into a corresponding range of cells in another worksheet.
Range("D13:P13").Cells(x).Value = cel.Offset(0, x).Value
I just found, though, that when one of the cells contains .0010, it comes across as .0000.
Both cells have the same number format, so I am nonplussed at this. My workaround, which solved the problem, is:
Range("D13:P13").Cells(x).Value = Val(CStr(cel.Offset(0, x).Value))
Somehow, casting the original value to a string, then back to a numeric value, makes it come out as .0010 as it should.
WHY was it not coming across correctly in the first place?
|