Problem With A Pesky Question during a Macro

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
 
G

Gary''s Student

After the copy, activate the "other" workbook and do the paste. Then close
"table.csv"
 
A

AltaEgo

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
 
P

Patrick Molloy

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
 

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