AutoFilter and copy

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

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(xlCellTypeVisible).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?
 
Change the 'Set rngSource' line to:

Set rngSource = ActiveSheet.Cells.SpecialCells(xlCellTypeVisible)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top