View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Billyruben Billyruben is offline
external usenet poster
 
Posts: 13
Default Activesheet.Paste does OK manually between worksheets but not

WOW OssieMac

I gathered from what you were saying that a Macro can span more than one
Workbook(W/B). (I am sorry; I kept saying WorkSheet when I should have been
saying WorkBook.) With that in mind, I started the Macro recorder and my
first step was to open W/B A. After selecting the desired range, I right
clicked and selected Copy. Next I went back to W/B B. Once I had selected
the appropriate cell, I right clicked and selected Paste. IT WORKED!

The final Macro looks like this:

Sub Macro16()
'
Windows("2008 Bank Statements.xls").Activate
Range("A21:D59").Select
Selection.Copy
Windows("Bank Statement Import Worksheet.xls").Activate
Range("C4").Select
ActiveSheet.Paste
End Sub

Since the data in W/B A varies in the number of rows from one month to the
next, I will first select the range that I need; then I will go to W/B B to
Run the Macro.

Ah, but that's a different story. Thanks for your help; it has been
educational as well.

Best Wishes

"OssieMac" wrote:

You need to select the required worksheet then the first cell of the range to
paste and then paste it. Like the full recorded macro below to copy and paste.

Range("A1:D7").Select
Selection.Copy
Sheets("Sheet2").Select
Range("B3").Select
ActiveSheet.Paste

If you have already selected the range and copied it before running the
macro to paste then it would look like this

Sheets("Sheet2").Select
Range("B3").Select
ActiveSheet.Paste


--
Regards,

OssieMac


"Billyruben" wrote:

Hey Simon

Sub Macro15()
'

' Macro recorded 11/28/2008 by Billy
'
ActiveSheet.Paste
Range("C4").Select
'
End Sub

While Running the Macro, it stops and I get a MS Visual Basic window
displaying:

Run-time error '1004':
Paste method of Worksheet class failed

"Simon Lloyd" wrote:


If the macro failed what was the error? what was the code you used to
perform the task? we need more than you gave to give you an answer!


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=34846