ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I address in autofilter FIELD with a value in a cell? (https://www.excelbanter.com/excel-programming/367094-can-i-address-autofilter-field-value-cell.html)

MakeLei

Can I address in autofilter FIELD with a value in a cell?
 
Hi,
Is there a possibility to use other than FIELD:=41 in row below?
Selection.AutoFilter Field:=41, Criteria1:="defined values"

What I have in mind is that I would like to be able to define the heading
cell value and use filtering in that column.

All comments and adise is valuable. Thanks in advancd

Tom Ogilvy

Can I address in autofilter FIELD with a value in a cell?
 
Dim rng as Range, res as Variant
set rng = selection.Rows(1).Cells
res = Application.Match("Header1",rng,0)
if not iserror(res) then
Selection.AutoFilter Field:=res, Criteria1:="defined values"
else
msgbox "header1 was not found"
End if

--
Regards,
Tom Ogilvy

"MakeLei" wrote:

Hi,
Is there a possibility to use other than FIELD:=41 in row below?
Selection.AutoFilter Field:=41, Criteria1:="defined values"

What I have in mind is that I would like to be able to define the heading
cell value and use filtering in that column.

All comments and adise is valuable. Thanks in advancd



All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com