永发信息网

帮看下,下列VBA代码:我要加一个条件 If Target.count = 6 Then 该怎样加进去呢?

答案:2  悬赏:60  手机版
解决时间 2021-03-11 14:55
  • 提问者网友:富士山上尢
  • 2021-03-10 14:12
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
If Target.count = 3 Then
If Target.Column = 5 And Target.Row = 3 Then
With Me.TextBox1
.Visible = True
.Top = Target.Top
.Left = Target.Left
.Width = Target.Width
.Height = Target.Height
.Activate
End With
With Me.ListBox1
.Visible = True
.Top = Target.Top
.Left = Target.Left + Target.Width
.Width = Target.Width * 1.5
.Height = Target.Height * 6
.Clear
For i = 2 To Sheet3.Range("A65536").End(xlUp).Row
.AddItem Sheet3.Cells(i, 1).Value
Next
End With

ElseIf Target.Column = 10 And Target.Row = 3 Then
With Me.TextBox1
.Visible = True
.Top = Target.Top
.Left = Target.Left
.Width = Target.Width
.Height = Target.Height
.Activate
End With
With Me.ListBox1
.Visible = True
.Top = Target.Top
.Left = Target.Left + Target.Width
.Width = Target.Width * 1.6
.Height = Target.Height * 6
.Clear
For i = 2 To Sheet3.Range("L65536").End(xlUp).Row
.AddItem Sheet3.Cells(i, 12).Value
Next
End With
Else
Me.ListBox1.Clear
Me.TextBox1 = ""
Me.ListBox1.Visible = False
Me.TextBox1.Visible = False
End If
End If
End Sub
最佳答案
  • 五星知识达人网友:神鬼未生
  • 2021-03-10 15:14
If Target.count = 3 Or Target.count = 6 Then
全部回答
  • 1楼网友:千杯敬自由
  • 2021-03-10 16:30
set xl = getobject(, "excel.application") 在vb中 建立一个 excel对象 然后用 xl.target.count>1 表示,就是涉及excel里面的特有关键字 都用xl. 前缀
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯