ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro cuts off decimals!? (https://www.excelbanter.com/excel-programming/282367-macro-cuts-off-decimals.html)

Allan[_3_]

macro cuts off decimals!?
 
Hi,
The program below copies a list of assumptions line-by-
line into a model and then records the output of the
model. This is the problem. When the program copies and
pastes the output from sheet1 back into sheet2, it simply
cuts off most of the decimals. Is it possible to instruct
the macro to keep these decimals?

Thanks,
Allan




Public Sub Model()

Dim cell As Range

For Each cell In Worksheets("sheet2").Range("N8:N327")

cell.Resize(1, 5).Copy

With Worksheets("sheet1")

.Range("B2").PasteSpecial Paste:=xlValues,
Transpose:=True

cell.Offset(0, -5).Value = .Range("B9").Value
cell.Offset(0, -4).Value = .Range("B10").Value
cell.Offset(0, -3).Value = .Range("B11").Value
cell.Offset(0, -2).Value = .Range("B12").Value

End With

Next

End Sub




Don Guillett[_4_]

macro cuts off decimals!?
 
try
format(yourrange,"whatever")
or
numberformat(same stuff)
--
Don Guillett
SalesAid Software

"Allan" wrote in message
...
Hi,
The program below copies a list of assumptions line-by-
line into a model and then records the output of the
model. This is the problem. When the program copies and
pastes the output from sheet1 back into sheet2, it simply
cuts off most of the decimals. Is it possible to instruct
the macro to keep these decimals?

Thanks,
Allan




Public Sub Model()

Dim cell As Range

For Each cell In Worksheets("sheet2").Range("N8:N327")

cell.Resize(1, 5).Copy

With Worksheets("sheet1")

.Range("B2").PasteSpecial Paste:=xlValues,
Transpose:=True

cell.Offset(0, -5).Value = .Range("B9").Value
cell.Offset(0, -4).Value = .Range("B10").Value
cell.Offset(0, -3).Value = .Range("B11").Value
cell.Offset(0, -2).Value = .Range("B12").Value

End With

Next

End Sub







All times are GMT +1. The time now is 08:34 PM.

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