Number Format Changes During VBA Copy/Paste

  • Thread starter Thread starter LarryP
  • Start date Start date
L

LarryP

I have an Excel workbook with VBA code that copies a series of numeric values
from sheet 2 and pastes them into corresponding cells in sheet 1. In one
case, the value in sheet 2 is 0.0170, but when pasted into sheet 1 it
displays as 0.0200. Both cell formats appear to be identical, there's no
rounding going on in the VBA, so can't for the life of me figure out why this
is happening. Anyone have an idea?

(Excel 2007 on Windows XP Pro)
 
I've continued to experiment, and discovered that the cell on sheet 2 was
formatted for Accounting/4 decimals/dollar sign, while the cell on sheet one
was set to Number/4 decimals/no thousands separator. Resetting the former to
match the latter appears to fix the problem, although if you can explain the
"why" part to me I'd be interested to hear it. I would have thought that
with both set to 4 decimals the transfer should have worked fine.
 
Back
Top