Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using Filters, Copy and Paste in a macro

Hi All,

I am trying to Copy the results of a filter into a
separate worksheet, but have found that it is copying the
occupied cells, plus all of the blank ones below. I don't
know how to only select the occupied cells, so I have
selected rows 2 - 1001.

The formula I am using is below:

Sub SecondStep()
'
' SecondStep Macro
' Macro recorded 18/02/2004 by Andy
'
Sheets("Raw Data").Activate
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="PB to Cust*"
Range("A2:F1001").Select
Selection.Copy
Sheets("CustbyRDC").Select
Range("A7").Select
ActiveSheet.Paste
Sheets("Raw Data").Select
'
End Sub



Please help!! I am at the end of my tether!!

Thanks in advance

Andy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Using Filters, Copy and Paste in a macro

Andy,

Replace

Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="PB to Cust*"
Range("A2:F1001").Select
Selection.Copy

with

With Range("A2").CurrentRegion
.AutoFilter Field:=2, Criteria1:="13"
.SpecialCells(xlVisible).Copy
.Copy
End With

HTH,
Bernie
MS Excel MVP

"Andy W" wrote in message
...
Hi All,

I am trying to Copy the results of a filter into a
separate worksheet, but have found that it is copying the
occupied cells, plus all of the blank ones below. I don't
know how to only select the occupied cells, so I have
selected rows 2 - 1001.

The formula I am using is below:

Sub SecondStep()
'
' SecondStep Macro
' Macro recorded 18/02/2004 by Andy
'
Sheets("Raw Data").Activate
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="PB to Cust*"
Range("A2:F1001").Select
Selection.Copy
Sheets("CustbyRDC").Select
Range("A7").Select
ActiveSheet.Paste
Sheets("Raw Data").Select
'
End Sub



Please help!! I am at the end of my tether!!

Thanks in advance

Andy



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
Macro - copy and paste value Howard Excel Discussion (Misc queries) 3 October 13th 09 07:38 AM
MSExcel 2007 Filters do not allow Copy and Paste of data Avril V Excel Discussion (Misc queries) 2 June 10th 09 06:04 PM
Copy/paste with filters from one sheet to another? krakatoakt Excel Discussion (Misc queries) 4 December 19th 07 08:12 PM
How to copy with filters but not copy the filters in the middle? ztalove Excel Discussion (Misc queries) 0 November 1st 06 04:53 PM
Macro to copy and paste Brian Excel Programming 0 August 28th 03 08:12 PM


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