Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default AutoFilter and copy

I am using Excel 97.

I want to accomplish the following. I want to set a filter then copy
the filtered data to the next available empty cell in the new report.
The code looks something like this.

Dim rngSource As Range, rngDestination As Range

Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=41, Criteria1:="FB"
Set rngSource = ActiveWorkbook.Cells.SpecialCells(xlCellTypeVisibl e).Copy
<- Crashes here on specialcells.
wbNew.Activate
Set rngDestination = ActiveWorkbook.Range(lcCell)
rngSource.Copy rngDestination

The help file says that specialcells returns a range. But I can not
seem to assign the filtered data to a range.

How can I do the above?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default AutoFilter and copy

Hi Rich

Set rngSource = ActiveWorkbook.Cells.SpecialCells(xlCellTypeVisibl e).Copy


Change to

Set rngSource = ActiveWorkbook.Cells.SpecialCells(xlCellTypeVisibl e)



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Rich" wrote in message om...
I am using Excel 97.

I want to accomplish the following. I want to set a filter then copy
the filtered data to the next available empty cell in the new report.
The code looks something like this.

Dim rngSource As Range, rngDestination As Range

Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=41, Criteria1:="FB"
Set rngSource = ActiveWorkbook.Cells.SpecialCells(xlCellTypeVisibl e).Copy
<- Crashes here on specialcells.
wbNew.Activate
Set rngDestination = ActiveWorkbook.Range(lcCell)
rngSource.Copy rngDestination

The help file says that specialcells returns a range. But I can not
seem to assign the filtered data to a range.

How can I do the above?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default AutoFilter and copy

Change the 'Set rngSource' line to:

Set rngSource = ActiveSheet.Cells.SpecialCells(xlCellTypeVisible)


Rich wrote:
I am using Excel 97.

I want to accomplish the following. I want to set a filter then copy
the filtered data to the next available empty cell in the new report.
The code looks something like this.

Dim rngSource As Range, rngDestination As Range

Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=41, Criteria1:="FB"
Set rngSource = ActiveWorkbook.Cells.SpecialCells(xlCellTypeVisibl e).Copy
<- Crashes here on specialcells.
wbNew.Activate
Set rngDestination = ActiveWorkbook.Range(lcCell)
rngSource.Copy rngDestination

The help file says that specialcells returns a range. But I can not
seem to assign the filtered data to a range.

How can I do the above?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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
Insert Row/Copy with Autofilter lilbit3684 Excel Discussion (Misc queries) 4 April 3rd 07 11:17 PM
Autofilter - copy & paste Dorothy Excel Worksheet Functions 0 May 29th 06 10:56 PM
Copy/Paste in Autofilter honyacker Excel Discussion (Misc queries) 2 January 12th 06 02:38 PM
Copy error with Autofilter Jonathan May[_3_] Excel Programming 0 July 15th 04 01:43 PM
Copy an autofilter range pauluk[_13_] Excel Programming 2 March 4th 04 04:28 PM


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