Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default runtime error 1004 paste method of worksheet class failed


Hi,

Very new to VBA and having trouble with a simple macro running in 2003
that copies and pasts to another worksheet. Code as follows:

Private Sub CopyResults_Click()
'Select the filtered data and copy it
Range("A23").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("F19").Select
' Open the template and copy in the data
Workbooks.Open Filename:="C:\Athens Verification
Data\Templates\Verification Template.xls"
Workbooks("Verification Template.xls").Activate
ActiveSheet.Range("A1").Select
*ActiveSheet.Paste*
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
End Sub

When I run CopyResults, the sheet is opened and the data copied
correctly, but I get a runtime error 1004 past method of worksheet
class failed, with the line 'ActiveSheet.Paste' highlighted. Don't get
this when I run the same macro in 2000.

Have looked for a solution online but no joy. Be grateful for any
advice!

Many thanks,

Jane


--
wilsoj
------------------------------------------------------------------------
wilsoj's Profile: http://www.excelforum.com/member.php...o&userid=24068
View this thread: http://www.excelforum.com/showthread...hreadid=376722

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default runtime error 1004 paste method of worksheet class failed


try ActiveSheet.PasteSpecial

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=376722

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default runtime error 1004 paste method of worksheet class failed

Private Sub CopyResults_Click()
Dim rng as Range, sh as Worksheet
'Select the filtered data and copy it
set rng = Range("A23")
set rng = Range(rng, rng.End(xlToRight))
set rng =Range(rng, rng.End(xlDown))
' Open the template and copy in the data
Workbooks.Open Filename:="C:\Athens Verification Data\Templates\Verification
Template.xls"
set sh = ActiveSheet
rng.copy Destination:=sh.Range("A1")
sh.range("A1").Select
End Sub

--
Regards,
Tom Ogilvy


"wilsoj" wrote in
message ...

Hi,

Very new to VBA and having trouble with a simple macro running in 2003
that copies and pasts to another worksheet. Code as follows:

Private Sub CopyResults_Click()
'Select the filtered data and copy it
Range("A23").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("F19").Select
' Open the template and copy in the data
Workbooks.Open Filename:="C:\Athens Verification
Data\Templates\Verification Template.xls"
Workbooks("Verification Template.xls").Activate
ActiveSheet.Range("A1").Select
*ActiveSheet.Paste*
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
End Sub

When I run CopyResults, the sheet is opened and the data copied
correctly, but I get a runtime error 1004 past method of worksheet
class failed, with the line 'ActiveSheet.Paste' highlighted. Don't get
this when I run the same macro in 2000.

Have looked for a solution online but no joy. Be grateful for any
advice!

Many thanks,

Jane


--
wilsoj
------------------------------------------------------------------------
wilsoj's Profile:

http://www.excelforum.com/member.php...o&userid=24068
View this thread: http://www.excelforum.com/showthread...hreadid=376722



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default runtime error 1004 paste method of worksheet class failed

I have had the same problem. What I am trying to do is copy the results of a
subtotal and when I try the below it copies everything. How can I just copy
the totals from the subtotal method?

Before I would do something like this:
Range(Cells(b, "A"), Cells(c, "B")).select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Tables").Select
Range("G1").Select
ActiveSheet.Paste


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default runtime error 1004 paste method of worksheet class failed


Sorted!! That's brill - many thanks.



--
wilso
-----------------------------------------------------------------------
wilsoj's Profile: http://www.excelforum.com/member.php...fo&userid=2406
View this thread: http://www.excelforum.com/showthread.php?threadid=37672



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default runtime error 1004 paste method of worksheet class failed

Sometimes opening workbooks can empty the clipboard. Maybe if you do things in
a slightly different order, things will be ok:

Option Explicit
Private Sub CopyResults_Click()
Dim curWks As Worksheet
Dim templWks As Worksheet
Dim rngToCopy As Range

Set curWks = ActiveSheet
With curWks
Set rngToCopy = .Range("a23", .Range("a23").End(xlToRight).End(xlDown))
End With

Workbooks.Open _
Filename:="C:\Athens Verification Data\" _
& "Templates\Verification Template.xls"

Set templWks = ActiveSheet

rngToCopy.Copy _
Destination:=templWks.Range("a1")

Application.CutCopyMode = False

End Sub



wilsoj wrote:

Hi,

Very new to VBA and having trouble with a simple macro running in 2003
that copies and pasts to another worksheet. Code as follows:

Private Sub CopyResults_Click()
'Select the filtered data and copy it
Range("A23").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("F19").Select
' Open the template and copy in the data
Workbooks.Open Filename:="C:\Athens Verification
Data\Templates\Verification Template.xls"
Workbooks("Verification Template.xls").Activate
ActiveSheet.Range("A1").Select
*ActiveSheet.Paste*
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
End Sub

When I run CopyResults, the sheet is opened and the data copied
correctly, but I get a runtime error 1004 past method of worksheet
class failed, with the line 'ActiveSheet.Paste' highlighted. Don't get
this when I run the same macro in 2000.

Have looked for a solution online but no joy. Be grateful for any
advice!

Many thanks,

Jane

--
wilsoj
------------------------------------------------------------------------
wilsoj's Profile: http://www.excelforum.com/member.php...o&userid=24068
View this thread: http://www.excelforum.com/showthread...hreadid=376722


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default runtime error 1004 paste method of worksheet class failed


Hi,

Many thanks to Tom and Dave. Both do the trick.

Clear that I still have a lot to learn...

Rgds, Jan

--
wilso
-----------------------------------------------------------------------
wilsoj's Profile: http://www.excelforum.com/member.php...fo&userid=2406
View this thread: http://www.excelforum.com/showthread.php?threadid=37672

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default runtime error 1004 paste method of worksheet class failed


Hi,
i tried copying Contents from a web application to an excel.
here i am providing a button to paste the contents that is in
Clipboard
while clicking the button i am getting this run time error at the first
time after that id i again copy the contents from the web application it
is not giving any error
i even tried pastespecial it also didn't work

please can any one suggest some ideas


--
shashikiran_g
------------------------------------------------------------------------
shashikiran_g's Profile: http://www.excelforum.com/member.php...o&userid=24180
View this thread: http://www.excelforum.com/showthread...hreadid=376722

Reply
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
Runtime 1004 error -- insert method of range class failed. tish Excel Discussion (Misc queries) 1 June 1st 07 04:04 PM
Run Time error 1004 Paste Method of Worksheet Class Failed Ken Nunn Excel Programming 3 June 29th 04 03:23 PM
Runtime Error '1004' - AddFields method of PivotTable class failed MikeC[_3_] Excel Programming 1 May 21st 04 06:58 AM
RUNTIME ERROR '1004' --- Select method of worksheet class failed jawee Excel Programming 2 April 30th 04 06:47 AM
runtime error '1004' delete Method of Range Class Failed Tom Kennedy Excel Programming 0 April 14th 04 08:08 PM


All times are GMT +1. The time now is 01:34 AM.

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"