Problem: Excel drops significant digits in copy value function...

G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top