On focus after tabbing of Excel drop down, automatically show list for selection

前端 未结 2 393
我在风中等你
我在风中等你 2020-12-12 01:37

I have some data validation drop down lists in excel, I can tab through all the lists but I have to press alt + down arrow to show the list, Is their a way it can be automat

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 02:27

    edit: still using VBA send keys.

    On the sheet where the data validation cell resides (assumed it is cells A1:C1 on Sheet1), put in the following code in the Microsoft Excel Sheet1 Module (the module that holds the VBA code that is related to the first sheet)

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        On Error GoTo Err1:
    
        If Target = Range("A1") Then
            Application.SendKeys ("%{UP}")
        End If
    
        If Target = Range("B1") Then
            Application.SendKeys ("%{UP}")
        End If
    
        If Target = Range("C1") Then
            Application.SendKeys ("%{UP}")
        End If
    
    Err1:
        'do nothing
    End Sub
    

提交回复
热议问题