Simple copy paste question

  • Thread starter Thread starter Z
  • Start date Start date
Z

Z

Hello!

I am developing a macro that begins by opening a .csv, copying all of
the data, pasting it into a worksheet, then closing the .csv file.
The problem is that it always prompts the user that there is a large
amount of data on the clipboard, etc. etc.

How can I make this message fail to appear so that the macro will run
without user intervention?

Thanks!
Z
 
Hi

You can use this (copy/paste in one line)

Sub test()
Dim WB As Workbook
Dim Mybook As Workbook
Application.ScreenUpdating = False
Set Mybook = ThisWorkbook
Set WB = Workbooks.Open("C:\Book.csv")
WB.Sheets(1).UsedRange.Copy Mybook.Sheets(1).Cells(1)
WB.Close False
Application.ScreenUpdating = True
End Sub


Or this after your paste line
Application.CutCopyMode = False
 
Application.CutCopyMode = False

Place this line at end of your macro code.

Gord Dibben Excel MVP
 
Back
Top