ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA code to locate cell address of AutoFilter dropdown box (https://www.excelbanter.com/excel-discussion-misc-queries/39456-vba-code-locate-cell-address-autofilter-dropdown-box.html)

Dennis

VBA code to locate cell address of AutoFilter dropdown box
 
XL 2003

What VBA code line would return the cell address of the cell containing the
AutoFilter dropdown box in a particular column

The line below does not work but gives an idea what I am looking for.

ActiveSheet.Autofilter.Address

Dennis

Bernie Deitrick

Dennis,

Try the code below.

HTH,
Bernie
MS Excel MVP

Sub Test()
Dim i As Integer
Dim mySheet As Worksheet
Set mySheet = ActiveSheet
Dim myFilters As String

myFilters = ""

For i = 1 To mySheet.AutoFilter.Range.Columns.Count
If mySheet.AutoFilter.Filters(i).On Then
myFilters = myFilters & mySheet.AutoFilter.Range _
.Cells(1, i).Address(False, False) & " & "
End If
Next i

MsgBox mySheet.Name & " range " & _
mySheet.AutoFilter.Range.Address & Chr(10) & _
"is filtered by cell(s) " & _
Left(myFilters, Len(myFilters) - 3)

End Sub



"Dennis" wrote in message
...
XL 2003

What VBA code line would return the cell address of the cell containing the
AutoFilter dropdown box in a particular column

The line below does not work but gives an idea what I am looking for.

ActiveSheet.Autofilter.Address

Dennis




Earl Kiosterud

Dennis

ActiveSheet.AutoFilter.Range.Row gives you the number of the heading row,
which contains the dropdowns.

The following will select the first one.
Roww = ActiveSheet.AutoFilter.Range.Row
Coll = ActiveSheet.AutoFilter.Range.Column
Cells(Roww, Coll).Select
--
Earl Kiosterud
www.smokeylake.com

"Dennis" wrote in message
...
XL 2003

What VBA code line would return the cell address of the cell containing
the
AutoFilter dropdown box in a particular column

The line below does not work but gives an idea what I am looking for.

ActiveSheet.Autofilter.Address

Dennis




Dennis

Thanks to both of you!

Different approaches both very useful.

I was close, but VBA likes neither horseshoes nor hand-grenades.

Dennis

*****************************************

"Dennis" wrote:

XL 2003

What VBA code line would return the cell address of the cell containing the
AutoFilter dropdown box in a particular column

The line below does not work but gives an idea what I am looking for.

ActiveSheet.Autofilter.Address

Dennis



All times are GMT +1. The time now is 01:56 PM.

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