View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Colin Hayes Colin Hayes is offline
external usenet poster
 
Posts: 465
Default VBA to Filter on variable column


Hi Claus

OK that's perfect.

Thanks for your time and considerable expertise.



Best Wishes


Colin






In article , Claus Busch
writes
Hi again,

Am Tue, 27 May 2014 16:14:24 +0200 schrieb Claus Busch:

.UsedRange.AutoFilter Field:=Columns(myArr(0)).Column, _
Criteria1:=IIf(myArr(2) = 0, Trim(myArr(1)), _
"*" & Trim(myArr(1)) & "*")


better change the lines above to:

.UsedRange.AutoFilter Field:=Columns(myArr(0)).Column, _
Criteria1:=IIf(UBound(myArr) = 1, Trim(myArr(1)), _
"*" & Trim(myArr(1)) & "*")

If you want filter for the exact value only enter the column letter and
the value. If you want filter for substring enter the third value e.g. 0
For exact value
C,LP
for substring
C,LP,0


Regards
Claus B.