LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Filter Copy/Paste Fails - Two Ranges Selected?


The Autofilter is turned on in the code below.

The copy/paste work (the data is transfered to another worksheet) but
the macro crashes on "WorkSheets("2005").PasteP - with the error
message: "Paste method of worksheet class failed."

When I look at the source worksheet I can see the "marching ants"
around two seperate ranges.

One range is the row that the filter itself is in (rows 2 through 7).
The filter is in Row 7. Rows 1 thorugh 6 are unneeded header
information.

The second range is the data that I am copy/pasting (and it works).

I have killed myself on this one for two days. Can anyone help this
undeserving Newbe?

I also need to find the last row of filtered data not hard code the
range (A2:Z157).

Craigm

---------------------------------
Sub Data_05()

Dim srceRng As Range
Dim destRng As Range
Dim i As Integer

'ActiveWindow.Visible = False
Worksheets("2005").Cells.Clear
Windows("060631 Charts_DataDown 3.xls").Activate
Sheets("Datadown").Select
Range("J7").Activate
Selection.AutoFilter Field:=13, Criteria1:="12/31/2004",
Operator:=xlAnd _
, Criteria2:="<7/1/2005"
Range("A1").Activate

'need to find the last row for the range not hard code it.
Set srceRng = Workbooks("060631 Charts_DataDown
3.xls").Sheets("Datadown").Range("A2:Z157")
srceRng.Copy

Sheets("2005").Select
Worksheets("2005").Activate

'ActiveSheet.Paste Destination:=Worksheets("2005").Range("A1")
Range("A1").Select
'ActiveSheet.Paste
'Crashes here but data is pasted
Worksheets("2005").Paste '****** Crashes here every time! ******

'Turn the filter off
Sheets("Datadown").Select
Rows("7:7").Select
Range("J7").Activate
Selection.AutoFilter
ActiveWindow.LargeScroll ToRight:=1
Selection.AutoFilter

End Sub


--
Craigm
------------------------------------------------------------------------
Craigm's Profile: http://www.excelforum.com/member.php...o&userid=24381
View this thread: http://www.excelforum.com/showthread...hreadid=387482

 
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
copy selected rows to second worksheet (NOT Cut + Paste) gyrra New Users to Excel 2 June 4th 10 09:05 PM
How can I copy big ranges of cells without drag or copy/paste? Ricardo Julio Excel Discussion (Misc queries) 3 March 23rd 10 02:38 PM
Why Copy/Paste fails using Offset & Resize of myRange? [email protected] Excel Discussion (Misc queries) 3 November 21st 06 02:06 AM
copy/paste selected worksheets mjack003 Excel Programming 3 January 28th 04 02:48 PM
How to Copy & Paste selected Range in Excel (MFC) Daniel Xu Excel Programming 6 November 25th 03 02:42 AM


All times are GMT +1. The time now is 11:44 PM.

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

About Us

"It's about Microsoft Excel"