LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
RW RW is offline
external usenet poster
 
Posts: 49
Default Prevent getting all rows if Autofilter criteria doesn't exist

I am using the following code to cycle through criteria. However, if the data
does not match the criteria, I get all of the rows pasted to the new sheet.
How can this be prevented?
WshName, FCriteria and FCriteria2 are arrays. This code works when the data
contains the 2 criteria.

For a = y To z
Sheets(WshName(x)).Select
Range("B1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:=FCriteria(a)
Range("C1").Select
Selection.AutoFilter Field:=3, Criteria1:=FCriteria2(a)
Application.CutCopyMode = False
Range("A2:AV" & EndCell).Select
Selection.Copy
Sheets(WshName(a)).Select
Range("A2").Select
ActiveSheet.Paste
Range("A2").Select
Next a
 
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
Selection.AutoFilter Field / Criteria = criteria sometimes non-existing on worksheet markx Excel Programming 1 November 24th 06 02:52 PM
Command Line. How to tell to XL : If the xls file exist : Open it, if it does not exist : Create it. Tintin92 Excel Programming 3 March 11th 06 06:45 PM
3 criteria must exist in adjoining cells then rtn val from 4th SteveH Excel Discussion (Misc queries) 2 January 23rd 06 03:13 PM
How to use autofilter to delete duplicate rows (2nd criteria) ? Mslady[_11_] Excel Programming 2 October 29th 05 06:36 PM
Prevent users from using AutoFilter Rob Savage Excel Programming 1 October 27th 03 11:42 AM


All times are GMT +1. The time now is 07:31 PM.

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"