|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
问题:
问题黄色部分,第一次点击窗体可以选择,第二次开始就无法选择了,谁能帮忙解释下!!!
- Dim Arr
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- 'If Target.Count > 5 Then GoTo 100
- If Target.Column <> 5 Or Target.Row <> 9 Then GoTo 100
- Arr = Application.Worksheets("sheet1").Range("a1").CurrentRegion
- With TextBox1
- .Activate
- .Visible = True
- .Value = ""
- .Top = Target.Top '+ Target.Height
- .Left = Target.Left
- .Width = 210
- .Height = Target.Height * 1.3
- .BackColor = RGB(255, 255, 150)
- End With
- With ListBox1
- .Visible = True
- .Top = Target.Offset(0).Top
- .Left = Target.Left + Target.Width 'Target.Left + Target.Width
- .Width = 200
- .Height = Target.Height * 10
- .BackColor = RGB(255, 255, 150)
- .Clear
- End With
- Exit Sub
- 100:
- ListBox1.Visible = False
- TextBox1.Visible = False
- End Sub
- Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
- Dim myStr$, i&
- Me.ListBox1.Clear
- If Me.TextBox1 <> "" Then
- With Me.TextBox1
- For i = 1 To Len(.Value)
- myStr = myStr & UCase(Mid$(.Value, i, 1))
- Next
- End With
- For i = 2 To UBound(Arr)
- If InStr(Arr(i, 1), myStr) Then
- Me.ListBox1.AddItem Arr(i, 1)
- End If
- Next
- Else
- For i = 2 To UBound(Arr)
- Me.ListBox1.AddItem Arr(i, 1)
- Next
- End If
- End Sub
- Private Sub ListBox1_Click()
- ActiveCell = ListBox1.Value
- ActiveCell.Offset(0, 1).Select
- ListBox1.Visible = False
- TextBox1.Visible = False
- End Sub
复制代码
|
|