ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copying values (https://www.excelbanter.com/excel-programming/369274-copying-values.html)

tom

copying values
 
Suppose sheet1.A1 has value 0.00 displayed on worksheet. Hoewever, the value
"0" is stored in the formula box. When I execute the code below, it displays
"0" on sheet2.A1 instead of 0.00. How can I make this operation give me 0.00?

sheet2.cells(1,1).value = sheet1.cells(1,1).value

Tiah

copying values
 
sheet2.cells(1,1).Copy destination:=sheet1.cells(1,1)
or
after your line put
sheet2.cells(1,1).numberformat=sheet1.cells(1,1).n umberformat

"tom" a écrit dans le message de news:
...
Suppose sheet1.A1 has value 0.00 displayed on worksheet. Hoewever, the
value
"0" is stored in the formula box. When I execute the code below, it
displays
"0" on sheet2.A1 instead of 0.00. How can I make this operation give me
0.00?

sheet2.cells(1,1).value = sheet1.cells(1,1).value




Jim Thomlinson

copying values
 
You need to set the number format something like this...

Sheet2.Cells(1, 1).Value = Sheet1.Cells(1, 1).Value
Sheet2.Cells(1, 1).NumberFormat = Sheet1.Cells(1, 1).NumberFormat

--
HTH...

Jim Thomlinson


"tom" wrote:

Suppose sheet1.A1 has value 0.00 displayed on worksheet. Hoewever, the value
"0" is stored in the formula box. When I execute the code below, it displays
"0" on sheet2.A1 instead of 0.00. How can I make this operation give me 0.00?

sheet2.cells(1,1).value = sheet1.cells(1,1).value


Tom Ogilvy

copying values
 
Add a second line of code like this:

sheet2.cells(1,1).value = sheet1.cells(1,1).value
sheet2.cells(1,1).NumberFormat = sheet1.cells(1,1).NumberFormat

--
Regards,
Tom Ogilvy



"tom" wrote:

Suppose sheet1.A1 has value 0.00 displayed on worksheet. Hoewever, the value
"0" is stored in the formula box. When I execute the code below, it displays
"0" on sheet2.A1 instead of 0.00. How can I make this operation give me 0.00?

sheet2.cells(1,1).value = sheet1.cells(1,1).value



All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com