Problem With A Pesky Question during a Macro

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

When running the below macro I get a dialog box asking if I want to keep &
use the data on the clipboard, which of course I do since I am pasting it
just a few lines down.
How can I keep this from happening?

Sub CopyTable

Windows("table.csv").Activate
Range("A1:G486").Select
Selection.Copy
ActiveWorkbook.Close
Range("W6").Select
ActiveSheet.Paste

End Sub
 
After the copy, activate the "other" workbook and do the paste. Then close
"table.csv"
 
Sub copyToBk2nClose()

Dim copyFrom As Range, copyTo As Range
Dim wksCopyTo As Worksheet
Set ThisWB = ActiveWorkbook
Set copyFrom = ThisWorkbook.Sheets("yourSheet").Range("A1:G486")
'change yourSheet
Set wksCopyTo = Workbooks("Book2.xls").Sheets("Sheet1")
'change Book2 and Sheet1
Set copyTo = wksCopyTo.Range("W6")
copyFrom.Copy
wksCopyTo.Paste copyTo
Application.CutCopyMode = False
ThisWorkBook.Close
End Sub
 
don't activate the table.csv workbook

Sub CopyTable

Windows("table.csv").Range("A1:G486").Copy
Range("W6").Paste
Application.CutCopyMode = False
workbooks("table.csv").Close False

End Sub
 
Back
Top