问题
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