|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Dim Sht As Worksheet
Private Sub ListBox1_Click()
ActiveCell = ListBox1.Text
TextBox1.Visible = False
ListBox1.Visible = False
[a1].Select
End Sub
Private Sub TextBox1_Change()
Dim rrrr As Range, N%
If TextBox1 = "" Then Exit Sub
ActiveCell = TextBox1.Text
With ListBox1
.Top = ActiveCell.Offset(1).Top
.Left = ActiveCell.Left
.Width = ActiveCell.Width + 125
.Visible = True
.Clear
For Each rrrr In Sht.Range("a1", Sht.[a65536].End(3))
If InStr(UCase(rrrr), UCase(TextBox1.Text)) > 0 Then
N = N + 1
.AddItem rrrr.Value
End If
Next
N = IIf(N > 12, 12, N)
.Height = 3 + N * 11
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
TextBox1.Visible = False: ListBox1.Visible = False
If Target.Address <> "$H$3" And Target.Address <> "$H$6" Then Exit Sub
If Target.Count > 1 Then Exit Sub
If Len(Target.Offset(-1)) < 1 Then Exit Sub
If Target.Address = "$H$3" Then Set Sht = Sheet3 Else Set Sht = Sheet1
With TextBox1
.Top = Target.Top
.Left = Target.Left
.Height = Target.Height
.Width = Target.Width + 125
.Visible = True
.Text = ""
.Activate
End With
End Sub
|
|