pasting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

I am trying to paste copied data from a csv file into another workbook's
"Input" sheet, starting at row 265. Basically, I have the following:

Workbooks.Open "source.csv"
DisplayAlerts = False
If Range("A2").Value > 0 Then 'file not empty
Range(Range("A2"), Range("M2").End(xlDown)).Select
Range(Range("A2"), Range("M2").End(xlDown)).Copy
Application.CutCopyMode = True 'prevent the following prompt: "There is a
large amount of information on the clipboard. Do yo uwant to be able to
paste this information into another program later?"
Application.ActiveWorkbook.Close savechanges:=False ' No need to save here
End If

'paste data from csv file, starting at row 265
Sheets("Input").Activate
Range(Range("A265"), Range("M265").End(xlDown)).Select
With ActiveSheet
.Range(.Range("A265"), .Range("M265").End(xlDown)).Copy _
Sheets("Input").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

I am not able to get this to work. Nothing is being pasted. Can someone
tell me why, and how to fix this?

Thanks in advance,
geebee
 
When you specify application.cutcopymode = false you remove what you just
copied. It will prevent the error message but it will render the copy
useless. You should paste prior to closing your file... Something like this...

dim wbkCopyFrom as Workbook

set wbkCopyFrom = Workbooks.Open("filename.csv")
with wbkCopyFrom
If .Range("A2").Value > 0 Then 'file not empty
.Range(.Range("A2"), .Range("O2").End(xlDown)).Copy _
ThisWorkbook.Sheets("Input").Range("A265")
End If
.Close savechanges:=False
end with
 

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

Back
Top