Excel Automatically Open Dropdown List with Focus / NumLock issue

牧云@^-^@ 提交于 2019-12-06 15:13:54

问题


I have a group of cells in my worksheet that use a data validation list. It works great, but I'd like the list to dropdown automatically when one of these cells gets the focus. I found some code online to make this work.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
   If Target.Worksheet.Name = "Sheet1" And Target.Column = 1 Then
       Application.SendKeys ("%{down}")
   End If
End Sub

Courtesy of: http://howoffice.com/automatically-open-the-drop-down-list-when-a-cell-get-focus-in-excel/

However, the issue I'm having is with the SendKeys causing the NumLock to toggle on and off. I looked this up and it's a known issue with the command.

Are there any other alternatives to the SendKey command to accomplish what I'm looking to do here?

Any help is appreciated.


回答1:


this code works for me :

    SendKeys "%{down}", True
    DoEvents
    SendKeys "{SCROLLLOCK}"


来源:https://stackoverflow.com/questions/28686687/excel-automatically-open-dropdown-list-with-focus-numlock-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!