Hi parmdeep,
Quote:
|
but if hes deceased (i know gruesome task) it displays Dec, Dec'd, or Deceased I should mention that since its been inputted manually it can be a mix of upper case and lower case characters. i.e. some have written DEC and some Dec and some dec etc.
|
Effectively then, using the advanced filter, the criteria for that column can just be "dec*", which will pick up any string beginning with the letters "dec" and is not case sensitive. Btw, you could implement some data validation to get the manual entries in that field consistent? A simple boolean flag would seem appropriate (is the person dead, TRUE/FALSE)?
Anyway, the criteria for the advanced filter are:
Column AL is Y
OR
Column AN is Y
OR
Column J is Dec*
This maps to a criteria range as follows:
Code:
Field 2 Field 3 Field 4
Y
Y
dec*
where the field headers in bold are the column headers in your table. Once that's set up the advanced filter is quite simple to automate. Each critereon is on it's own row which signifies OR conditions.
I've attached an example to show you. The code in the example is simply:
Code:
Range("B13:E1000").AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=Range("Criteria"), _
CopyToRange:=Range("Extract"), _
Unique:=False
where Range("B13:E1000") is the source table. Of course, the dimensions (number of rows) of the source table can be determined dynamically at runtime. In the example I've added some conditional formatting just to indicate which rows meet the criteria to be shown in the results area.
For learning purposes, if you want me to go over the loop approach you were trying to employ then let me know.
Hope that helps...