View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ivano Ivano is offline
external usenet poster
 
Posts: 28
Default efficient code to copy/paste

Thanks Don, it works.

"Don Guillett" wrote:

This assumes your macro fired from the destination workbook.

Sub copyvaluesfrom()
Workbooks("sourc.xls").Sheets("sheet1").Range("a2: a22").Copy
Range("a6").PasteSpecial Paste:=xlPasteValues
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ivano" wrote in message
...
Hi,
I need to copy and paste various cells within various tabs for various
worksheets to other worksheets. So, through the Record Macro feature it
came
up with a bunch of code that records every click and step but I want to
make
it more efficient. This is part of the code:

Windows("Workbook1.xls").Activate
Sheets("Benefit Analysis - Salary").Select
Range("A6:F19").Select
Selection.Copy
Windows("Workbook2.xls").Activate
Sheets("Benefit Analysis - Salary").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Is there way in a single comand line I can tell it to:
copy range "A6:F19" from "Benefit Analysis - Salary" from "workbook1"
paste values to range "A6" of "Benefit Analysis - Salary" from "workbook2"

Thanks
Ivano