SendKeys to show Filter window in filtered column & put cursor in Search field

2Took

Board Regular
Joined
Jun 13, 2022
Messages
203
Office Version
  1. 365
Platform
  1. Windows
Once in filtered column header, it takes holding Alt and pressing Down Arrow to get filter window to show. Then it takes 8 Down Arrows to get cursor to end up in Search field. Below code fails...

VBA Code:
Sub DropFilter()
    Range("E3").Select
    Application.SendKeys ("% + {Down}")
    Application.SendKeys ("{Down 8}")
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Any reason why you're not using the AutoFilter method of the Range object?

In any case, try...

VBA Code:
Sub DropFilter()
    Range("a1").Select
    Application.SendKeys ("%{Down}")
    Dim i as Long
    For i = 1 To 8
        Application.SendKeys ("{Down}")
    Next i
End Sub
 
Upvote 0
Any reason why you're not using the AutoFilter method of the Range object?

If AutoFilter method of the Range object can accomplish the objective -- I'd love to see that code, as I understand SendKeys is recommended to be avoided

 
Upvote 0
Well, let's say that Sheet1 contains your data, and that the data starts at A1, and that Row 1 contains your headers, and that you want to filter Column E for "X"...

VBA Code:
Worksheets("Sheet1").UsedRange.AutoFilter field:=5, Criteria1:="X"

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top