View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default 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