Using Autofilter if criteria is not in list

nehpets12

Active Member
Joined
Feb 22, 2002
Messages
453
I want to check the Criteria in the filter list and if there is not a 1 then I dont want it to copy anything.

At the moment if there is not a 1 it copies whole sheet!!!




Code:
Sheets("Machine Information").Select
    Range("A65536").End(xlUp).Offset(0, 0).Range("A1").Select
    Myfilter = ActiveCell.Row
    Cells.Select
    
    Selection.AutoFilter
    Selection.AutoFilter Field:=4, Criteria1:="1"
    Range("a2:C" & Myfilter).Select
    Selection.Copy
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try selecting only the visible cells:

Range("a2:C" & Myfilter).SpecialCells(xlCellTypeVisible).Select
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,546
Messages
5,838,021
Members
430,526
Latest member
NiceGuyWithExcel2007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top