Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA - Autofilter, Selects all when criteria not found

Status
Not open for further replies.

BatFace

Technical User
Oct 17, 2001
24
AU
Thanks again for your help!

I am using the following code to copy data according to autofilter criteria - this works fine, until there is no data marked as &quot;sold&quot; - it then copies the whole sheet...what code would I use to exit sub if criteria is <> &quot;Sold&quot;?

Columns(&quot;b:q&quot;).Select
Selection.AUTOFILTER
Selection.AUTOFILTER Field:=16, Criteria1:=&quot;Sold&quot;
Range(Cells(2, 4), Cells(lastRow,_
16)).Interior.ColorIndex = xlNone
Range(Cells(2, 4), Cells(lastRow, 16)).Copy

Thanks again for your help!


[bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top