Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Shirley Munro
 
Posts: n/a
Default Copying Filtered Data


I am running a Macro which filters data into 4 separate workbooks. I
then need to copy the filtered data into the one workbook but when I do
this it is copying the full 65,000 rows. Is there something I can
record in a Macro that will only copy down to the last cell with a
value in it. The number of rows is going to change each time the macro
runs so I can't select the filtered data by itself.

thanks


--
Shirley Munro
------------------------------------------------------------------------
Shirley Munro's Profile: http://www.excelforum.com/member.php...nfo&userid=836
View this thread: http://www.excelforum.com/showthread...hreadid=381239

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Does the problem exist in the Filtered range or does it exist in your code that
does the copying?

If you're filtering the whole worksheet, then this won't work. But if you're
copying rows (from 2 to the bottom of the worksheet--not the bottom of the
filtered range), it should work ok.

Option Explicit
Sub testme()

Dim fWks As Worksheet
Dim tWks As Worksheet

Dim rng As Range
Dim rngF As Range

Dim destCell As Range

Set fWks = Worksheets("sheet1")
Set tWks = Worksheets("sheet2")

With tWks
Set destCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

With fWks
Set rng = .AutoFilter.Range
With rng
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1 Then
MsgBox "No detail rows shown!"
Else
Set rngF = .Resize(.Rows.Count - 1, .Columns.Count).Offset(1, 0)
rngF.Copy _
Destination:=destCell
End If
End With
End With

End Sub

This actually copies the details--it doesn't include the autofilter header row.

Shirley Munro wrote:

I am running a Macro which filters data into 4 separate workbooks. I
then need to copy the filtered data into the one workbook but when I do
this it is copying the full 65,000 rows. Is there something I can
record in a Macro that will only copy down to the last cell with a
value in it. The number of rows is going to change each time the macro
runs so I can't select the filtered data by itself.

thanks

--
Shirley Munro
------------------------------------------------------------------------
Shirley Munro's Profile: http://www.excelforum.com/member.php...nfo&userid=836
View this thread: http://www.excelforum.com/showthread...hreadid=381239


--

Dave Peterson
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
Sort pages? David Excel Discussion (Misc queries) 15 May 13th 05 11:33 PM
Adding more source data to existing scatter plot Tom Charts and Charting in Excel 1 March 21st 05 10:03 PM
Conditional data validation (using a filtered range?) Simon Excel Worksheet Functions 0 February 15th 05 02:39 PM
Formula for copying data for every 8th cell jbsand1001 Setting up and Configuration of Excel 5 January 4th 05 02:08 PM
Running Data Table using an input that triggers DDE linked data [email protected] Excel Discussion (Misc queries) 1 December 16th 04 11:56 AM


All times are GMT +1. The time now is 06:21 AM.

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"