LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default efficient code to copy/paste

I ran into a snag. A1 to D1 are merged and A2 to D2 are also merged

from workbook1 - ".Range("A1:D2").copy" and
to workbook2 - ".Range("A5:D6").PasteSpecial Paste:=xlPasteValues

I get runtime error: PasteSpecial method of Range class failed

But if I change the destination of workbook2 to paste to A1:D2 then it
works... it's like I can't past special to any other destination other then
where it got copied from?

any ideas?


"Ivano" wrote:

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Efficient Code to Copy a 1-D Array to a Worksheet Column Tom Ogilvy Excel Programming 4 December 7th 06 04:27 PM
Copy & Paste code more efficient Desert Piranha[_102_] Excel Programming 12 August 16th 06 04:51 AM
More efficient copy/paste?? Celt[_64_] Excel Programming 6 June 9th 06 07:21 PM
Efficient Copy/Paste William Benson[_2_] Excel Programming 4 September 8th 05 07:42 PM
More efficient method to copy-paste values in place? quartz[_2_] Excel Programming 4 November 15th 04 01:54 PM


All times are GMT +1. The time now is 06:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"