Home > Software engineering >  Excel with vba to realize the drop-down menu, don't know how to add a display the drop-down men
Excel with vba to realize the drop-down menu, don't know how to add a display the drop-down men

Time:03-11



When the judge as ever, the same Banks listed click won't appear the drop-down menu, can input






Private Sub ListBox1_Click ()
ActiveCell. Value=https://bbs.csdn.net/topics/Me.ListBox1.Value
Me. The ListBox1. Visible=False
Me. TextBox1. Visible=False
End Sub




Private Sub TextBox1_Change ()
Dim arr, I % % j, d
The Set d=CreateObject (" scripting. The dictionary ")
Arr=Sheet2. Range (" A1 "). CurrentRegion
For I=2 To UBound (arr)
If InStr (arr (I, 1), Me. TextBox1. Value) Then
D (arr (I, 1))=""

End the If
Next
Me. The ListBox1. Clear
If, dc mount & gt;=1 Then Me. ListBox1. List=d.k eys

End Sub

Private Sub Worksheet_SelectionChange (ByVal Target As Range)
If Target. Count & gt; 1 Then Me. TextBox1. Visible=False: Me. ListBox1. Visible=False: Exit Sub
If the Target. The Column & lt;> 3 Then Me. TextBox1. Visible=False: Me. ListBox1. Visible=False: Exit Sub
If the Target. The Row & lt; 7 Then Me. TextBox1. Visible=False: Me. ListBox1. Visible=False: Exit Sub
Dim arr, I % % j, d
The Set d=CreateObject (" scripting. The dictionary ")
Arr=Sheet2. Range (" A1 "). CurrentRegion
For I=2 To UBound (arr)
D (arr (I, 1))=""
Next
With Me. The TextBox1
. The Top=Target. The Top
. Left=Target. Left
. Width=Target. Width
. The Height=Target. Height
. Activate
. Valuehttps://bbs.csdn.net/topics/=""
The Visible=True
End With
With Me. The ListBox1
. The Clear
. The Top=Target. The Offset (0, 1). The Top
. Left=Target. Offset (0, 1). Left
. The Height=Target. The Offset (0, 1). Height * 4
. Width=Target. Offset (0, 1). The Width

The List=d.k eys
The Visible=True
End With
End Sub
  •  Tags:  
  • VBA
  • Related