• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

issue getting criteria1 when 2 filter-items are selected

Héctor Miguel

New Member
hi, All !

I can get a single data when only one item is selected
I can get an array of data when three or more items are selected
I can not get an array if two (only and exactly two) items are selected

tested with:
sheet1.autofilter.filters(1).criteria1
sheet1.listobjects(1).autofilter.filters(1).criteria1

am I missing something ?
anyone to the rescue, plis ?

TIA,
hector.
 
Dear Hector,

May be requirenent to run this macro is Both criteria"s data should be mustl on same sheet.
But how to make this happen is matter of experts from this site who may be guide how to
Sucesdfully achieve results though data on multi sheets.

Regards,
Chirag Raval
 
Hector

Firstly, Welcome to the Chandoo.org Forums

Can you please post your file and code so we can see what's going on ?
 
Hi ,

When a single item is selected in an autofilter , using Criteria1 returns the selected value.

When two items are selected in an autofilter , using Criteria1 returns the first selected value. Criteria2 returns the second selected value.

When 3 or more items are selected , Excel generates an array of selected values using Criteria1 itself ; displaying all the selected values can be done by displaying the items in the array of values.

Thus , the code has to identify the difference before it can display all selected values.

Using the following :

Typename(w.AutoFilter.Filters.Item(?).Criteria1)

where the ? stands for the column number on which the filter has been applied , will return String for the first two cases , and Variant() in the third case.

Code has to take this into account.

Narayan
 
Back
Top