ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem: Excel drops significant digits in copy value function... (https://www.excelbanter.com/excel-programming/346875-problem-excel-drops-significant-digits-copy-value-function.html)

MikeZz

Problem: Excel drops significant digits in copy value function...
 
I know there are certainly more efficient ways of managing this data and
should be in a database but this is what I have to work with right now.

Basically, I am copying values from one sheet to an equivilant sheet over a
specified range of cells.

The problem is that the value in the original sheet can be say: "1.2345".
It's copied into the var: newvalue as "1.2345" but this is what happens:
Sheets(tosheet).Range(start_range).Offset(row, col).Value turns into: "1.23"

Excel or VBA rounds the value to 2 decimals and pastes the rounded value
into the new sheet. I need it to paste the actual value.

Thanks for the help!
MikeZz

Here's a copy of my Sub:
===================
Sub CopyDataFromSheetToSheet(row1, row2, col1, col2, fromsheet, tosheet,
start_range)
Dim row, newvalue, col
'This copies all non-locked cells from equivalent sheets.
For row = row1 To row2
For col = col1 To col2
If Sheets(tosheet).Range(start_range).Offset(row, col).Locked =
False Then
newvalue = Sheets(fromsheet).Range(start_range).Offset(row,
col).Value
Sheets(tosheet).Range(start_range).Offset(row, col).Value =
newvalue
End If
Next
Next
End Sub

Gary''s Student

Problem: Excel drops significant digits in copy value function...
 
Try:
Tools Options Edit

and clear the fixed decimal checkbox
--
Gary's Student


"MikeZz" wrote:

I know there are certainly more efficient ways of managing this data and
should be in a database but this is what I have to work with right now.

Basically, I am copying values from one sheet to an equivilant sheet over a
specified range of cells.

The problem is that the value in the original sheet can be say: "1.2345".
It's copied into the var: newvalue as "1.2345" but this is what happens:
Sheets(tosheet).Range(start_range).Offset(row, col).Value turns into: "1.23"

Excel or VBA rounds the value to 2 decimals and pastes the rounded value
into the new sheet. I need it to paste the actual value.

Thanks for the help!
MikeZz

Here's a copy of my Sub:
===================
Sub CopyDataFromSheetToSheet(row1, row2, col1, col2, fromsheet, tosheet,
start_range)
Dim row, newvalue, col
'This copies all non-locked cells from equivalent sheets.
For row = row1 To row2
For col = col1 To col2
If Sheets(tosheet).Range(start_range).Offset(row, col).Locked =
False Then
newvalue = Sheets(fromsheet).Range(start_range).Offset(row,
col).Value
Sheets(tosheet).Range(start_range).Offset(row, col).Value =
newvalue
End If
Next
Next
End Sub



All times are GMT +1. The time now is 06:09 PM.

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