Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JRF JRF is offline
external usenet poster
 
Posts: 5
Default Copying sheets and PasteSpecial

The following code fails if autofilter is filtering rows. How do I
adapt my code to make it work? The goal is to copy a sheet and then
replace all formuals with values.

Sheets(strSheetName).Copy
After:=wkbNewWorkbook.Sheets(wkbNewWorkbook.Sheets .Count)
ActiveSheet.Cells.Copy
ActiveSheet.Cells.PasteSpecial xlValues

  #3   Report Post  
Posted to microsoft.public.excel.programming
JRF JRF is offline
external usenet poster
 
Posts: 5
Default Copying sheets and PasteSpecial

I tried the code as suggested but still got the same error...

Run-time error '1004':
The information cannot be pasted because the copy area and the paste
area are not the same size and shape....

Again, the problem only occurs when the source sheet has autofiltered
data.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Copying sheets and PasteSpecial

try this instead

Sub Macro1()
x = Cells(Rows.Count, "a").End(xlUp).Row
Sheets("Sheet2").Copy Befo=Sheets(2)
Range("a2:b" & x) = Range("a2:b" & x).Value
' Cells.Copy
' Cells.PasteSpecial Paste:=xlPasteValues
End Sub

--
Don Guillett
SalesAid Software

"JRF" wrote in message
ups.com...
I tried the code as suggested but still got the same error...

Run-time error '1004':
The information cannot be pasted because the copy area and the paste
area are not the same size and shape....

Again, the problem only occurs when the source sheet has autofiltered
data.



  #5   Report Post  
Posted to microsoft.public.excel.programming
JRF JRF is offline
external usenet poster
 
Posts: 5
Default Copying sheets and PasteSpecial

I ended up copying out the autofilter to an array, turning off
autofilter, copying the sheet, then copyinging back in the array, then
turning autofiler back on. It took a bit but it works well. Thanks for
your help.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Copying sheets and PasteSpecial

Try what I did. It tested well.

--
Don Guillett
SalesAid Software

"JRF" wrote in message
oups.com...
I ended up copying out the autofilter to an array, turning off
autofilter, copying the sheet, then copyinging back in the array, then
turning autofiler back on. It took a bit but it works well. Thanks for
your help.



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
Copying Sheets Stacy C[_2_] Excel Discussion (Misc queries) 3 July 27th 09 11:03 PM
Copying sheets j.ruderman[_2_] Excel Worksheet Functions 1 October 7th 08 12:41 AM
copying sheets fastballfreddy Excel Discussion (Misc queries) 2 May 5th 06 07:20 AM
Copying Sheets ben Excel Programming 5 March 28th 05 04:51 PM
Copying from other sheets Vadiraj Excel Programming 1 January 29th 04 09:19 AM


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