|
Private Sub ListBox1_Click()
ActiveCell.Value = Me.ListBox1.Value
Me.ListBox1.Visible = False
Me.TextBox1.Visible = False
End Sub
Private Sub TextBox1_Change()
Dim arr, i%, j%, d
Set d = CreateObject("scripting.dictionary")
arr = Sheet6.Range("B3").CurrentRegion
For i = 2 To UBound(arr)
If InStr(arr(i, 1), Me.TextBox1.Value) Then
d(arr(i, 1)) = ""
End If
Next
Me.ListBox1.Clear
If d.Count >= 1 Then Me.ListBox1.List = d.keys
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Me.TextBox1.Visible = False: Me.ListBox1.Visible = False: Exit Sub
If Target.Column <> 2 Then Me.TextBox1.Visible = False: Me.ListBox1.Visible = False: Exit Sub
If Target.Row < 6 Then Me.TextBox1.Visible = False: Me.ListBox1.Visible = False: Exit Sub
Dim arr, i%, j%, d
Set d = CreateObject("scripting.dictionary")
arr = Sheet6.Range("B3").CurrentRegion
For i = 2 To UBound(arr)
d(arr(i, 1)) = ""
Next
With Me.TextBox1
.Top = Target.Top
.Left = Target.Left
.Width = Target.Width
.Height = Target.Height
.Activate
.Value = ""
.Visible = True
End With
With Me.ListBox1
.Clear
.Top = Target.Offset(0, 1).Top
.Left = Target.Offset(0, 1).Left
.Height = Target.Offset(0, 1).Height * 21
.Width = Target.Offset(0, 1).Width
.List = d.keys
.Visible = True
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Union(Target, Range("J3")).Address <> Range("J3").Address Then
Exit Sub
End If
sDate = Target.Value
MyCalendar.Show
If IsDate(sDate) Then
Target.Value = sDate
sDate = "'"
End If
End Sub
|
|