Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Error in PasteSpecial ?

=====================================
Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook
Sheets("ZZZ").Select
End With
With activeworksheet
Range("a1:u41").Copy
Sheets("AAA").Select
'Worksheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Range("A1").PasteSpecial <============== ERROR
End With
End Sub
=====================================

I am using the above code to copy and paste values froM another worksheet.
I WANT THE FORMAT AND VALUES COPIED, which the abovew does, however,
I get a "Method of 'PasteSpecial' of Object 'Range' Failed error".
If i click end ALL is fine, how can i rid the code of the error alert?


Corey


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Error in PasteSpecial ?

You haven't given the pastespecial method enough arguments. It should
be something like:

Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats

or

Range("A1").PasteSpecial Paste:=xlPasteAll

or one of the other constants that should expose itself to you via
intellisense. To see them all, type in the xlPaste portion, and then
hit Ctrl+Spacebar. The Intellisense will give you the listing of
constants starting at the Paste portion. Scroll through them to see
which you're after.

HTH,

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca

Corey wrote:
=====================================
Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook
Sheets("ZZZ").Select
End With
With activeworksheet
Range("a1:u41").Copy
Sheets("AAA").Select
'Worksheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Range("A1").PasteSpecial <============== ERROR
End With
End Sub
=====================================

I am using the above code to copy and paste values froM another worksheet.
I WANT THE FORMAT AND VALUES COPIED, which the abovew does, however,
I get a "Method of 'PasteSpecial' of Object 'Range' Failed error".
If i click end ALL is fine, how can i rid the code of the error alert?


Corey


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Error in PasteSpecial ?

Thanks for the reply.
I am trying the :

Range("A1").PasteSpecial Paste:=xlPasteAll

code but i still seems to get the same error.???

--
Regards

Corey


"Ken Puls" wrote in message
.. .
You haven't given the pastespecial method enough arguments. It should be
something like:

Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats

or

Range("A1").PasteSpecial Paste:=xlPasteAll

or one of the other constants that should expose itself to you via
intellisense. To see them all, type in the xlPaste portion, and then hit
Ctrl+Spacebar. The Intellisense will give you the listing of constants
starting at the Paste portion. Scroll through them to see which you're
after.

HTH,

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca

Corey wrote:
=====================================
Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook
Sheets("ZZZ").Select
End With
With activeworksheet
Range("a1:u41").Copy
Sheets("AAA").Select
'Worksheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Range("A1").PasteSpecial <============== ERROR
End With
End Sub
=====================================

I am using the above code to copy and paste values froM another
worksheet.
I WANT THE FORMAT AND VALUES COPIED, which the abovew does, however,
I get a "Method of 'PasteSpecial' of Object 'Range' Failed error".
If i click end ALL is fine, how can i rid the code of the error alert?


Corey



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Error in PasteSpecial ?

Sorry, I just looked at the line you said you errored on. Your code had
an issue higher up that should have errored out. There is no such
object as "activeworksheet". You'd need to change that to ActiveSheet.

Regardless, it isn't necessary to select each item all the time. Try
this shortened version of your code:

Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
Sheets("ZZZ").Range("a1:u41").Copy
Sheets("AAA").Range("A1").PasteSpecial Paste:=xlPasteAll
End Sub

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca

Corey wrote:
Thanks for the reply.
I am trying the :

Range("A1").PasteSpecial Paste:=xlPasteAll

code but i still seems to get the same error.???

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Error in PasteSpecial ?

Thnaks again.
I now get a different error when i run the simplified code you posted.

I get a :-




Automation error.
The object invoked has disconnected from its clients.





Never seen that before??


--
Regards

Corey
"Ken Puls" wrote in message
...
Sorry, I just looked at the line you said you errored on. Your code had
an issue higher up that should have errored out. There is no such object
as "activeworksheet". You'd need to change that to ActiveSheet.

Regardless, it isn't necessary to select each item all the time. Try this
shortened version of your code:

Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
Sheets("ZZZ").Range("a1:u41").Copy
Sheets("AAA").Range("A1").PasteSpecial Paste:=xlPasteAll
End Sub

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca

Corey wrote:
Thanks for the reply.
I am trying the :

Range("A1").PasteSpecial Paste:=xlPasteAll

code but i still seems to get the same error.???





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Error in PasteSpecial ?

Very strange... There is nothing in that code that should cause an
automation error.

Have you tried saving your document, closing Excel and re-opening it?

Also, is there any other code that runs in this workbook?

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca

Corey wrote:
Thnaks again.
I now get a different error when i run the simplified code you posted.

I get a :-




Automation error.
The object invoked has disconnected from its clients.





Never seen that before??


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Error in PasteSpecial ?

Maybe try:

Range("A1").activate
activesheet.PasteSpecial <============== ERROR

or

Range("A1").select
selection.pastespecial

Regards,
Paul
"Corey" wrote in message
...
=====================================
Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook
Sheets("ZZZ").Select
End With
With activeworksheet
Range("a1:u41").Copy
Sheets("AAA").Select
'Worksheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Range("A1").PasteSpecial <============== ERROR
End With
End Sub
=====================================

I am using the above code to copy and paste values froM another worksheet.
I WANT THE FORMAT AND VALUES COPIED, which the abovew does, however,
I get a "Method of 'PasteSpecial' of Object 'Range' Failed error".
If i click end ALL is fine, how can i rid the code of the error alert?


Corey



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Error in PasteSpecial ?

Still get the same error also?



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Error in PasteSpecial ?

I actually don't get any errors running your code. Check to make sure your
sheet names match your code.

Regards,
Paul

"Corey" wrote in message
...
Still get the same error also?





  #10   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Error in PasteSpecial ?

Hi Corey-

The placement of the second 'end with' statement is producing your error;
within your 'with activeworksheet' block, you change the worksheet... Try
moving the second 'end with' statement up in the code as in the following:

Sub TimeSheets2()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook
Sheets("ZZZ").Select
End With
With activeworksheet
Range("a1:u41").Copy
End With
Sheets("AAA").Select
'Worksheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Range("A1").PasteSpecial

End Sub


--
Thanks,
Jay


"PCLIVE" wrote:

Maybe try:

Range("A1").activate
activesheet.PasteSpecial <============== ERROR

or

Range("A1").select
selection.pastespecial

Regards,
Paul
"Corey" wrote in message
...
=====================================
Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook
Sheets("ZZZ").Select
End With
With activeworksheet
Range("a1:u41").Copy
Sheets("AAA").Select
'Worksheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Range("A1").PasteSpecial <============== ERROR
End With
End Sub
=====================================

I am using the above code to copy and paste values froM another worksheet.
I WANT THE FORMAT AND VALUES COPIED, which the abovew does, however,
I get a "Method of 'PasteSpecial' of Object 'Range' Failed error".
If i click end ALL is fine, how can i rid the code of the error alert?


Corey






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Error in PasteSpecial ?

will this do what you want?

Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook.Sheets("ZZZ")
.Select
.Range("a1:u41").Copy
Sheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Sheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
End With
End Sub

--


Gary


"Corey" wrote in message
...
=====================================
Sub TimeSheets()
Sheets("AAA").Range("A1:U41").Insert
With ActiveWorkbook
Sheets("ZZZ").Select
End With
With activeworksheet
Range("a1:u41").Copy
Sheets("AAA").Select
'Worksheets("AAA").Range("A1:U42").PasteSpecial Paste:=xlPasteValues
Range("A1").PasteSpecial <============== ERROR
End With
End Sub
=====================================

I am using the above code to copy and paste values froM another worksheet.
I WANT THE FORMAT AND VALUES COPIED, which the abovew does, however,
I get a "Method of 'PasteSpecial' of Object 'Range' Failed error".
If i click end ALL is fine, how can i rid the code of the error alert?


Corey



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
PasteSpecial Error 1004? DaveM Excel Discussion (Misc queries) 3 February 7th 08 02:41 PM
PasteSpecial Method Error PW11111 Excel Discussion (Misc queries) 1 December 19th 06 01:24 PM
PasteSpecial error handling JakeyC Excel Programming 3 October 6th 05 07:26 PM
PasteSpecial error Robert Christie[_3_] Excel Programming 4 December 27th 04 10:37 PM
PasteSpecial Error sowetoddid[_14_] Excel Programming 3 April 28th 04 12:14 AM


All times are GMT +1. The time now is 04:11 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"