PDA

View Full Version : Solved: Copy and Paste Problem



fif_rumac
02-05-2007, 05:12 AM
Hello All,

Please forgive me if I am missing something really obvious here...

I have 2 WorkSheets on different WorkBooks. I have created code to copy a range (A1:C1) from Sheet1 and paste it to sheet2. The problem is that although the code seems to copy ok, when the paste code runs it does not paste over the values from the range. It pastes 0 in each cell.

Does someone know what the problem might be?

Thanks,

fif_rumac

moa
02-05-2007, 05:33 AM
Can you post your code?

fif_rumac
02-05-2007, 05:38 AM
Sub AddToDataStore()
Dim ThisRow As Long

ThisWorkbook.Sheets("INPUT").Range("aa1:br1").Copy

Workbooks.Open Filename:="C:\test\datastore.xls", UpdateLinks:=False

For ThisRow = 2 To 65535
If Len(Trim(Workbooks("datastore.xls").Sheets("Sheet1").Range("datastoreheader").Cells(ThisRow, 1).Text)) = 0 Then
Workbooks("datastore.xls").Activate
Range("A" & Trim(Str(ThisRow)) & ":A" & Trim(Str(ThisRow))).Select
ActiveSheet.Paste
Exit For
End If
Next ThisRow

End Sub

Bob Phillips
02-05-2007, 05:47 AM
Maybe the source is formulae that are being updated on pasting. Maybe try



Range("A1").PasteSpecial Paste:=xlPasteValues