|
发表于 2016-6-10 20:23
|
显示全部楼层
本楼为最佳答案
具体原因不明,在一下代码的最后加了
ActiveWindow.ScrollRow = TR - 1
ActiveWindow.ScrollRow = TR
你试试,加了之后我这边运行正常,相当于模拟鼠标滑轮滑动,你之前说的延迟也不是,鼠标滑动一下就可以了!- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim TR%, TC%, strV() As String, intI%, intL%
- TR = Target.Row: TC = Target.Column
- ListBox1.Visible = False
- ListBox1.Locked = True
- ListBox1.Locked = False
- If TR > 1 And TR <= 281 And Target.Count = 1 Then
- If TC = 7 Then
- ActiveWindow.ScrollRow = TR
- With ListBox1
- .MultiSelect = 0
- .ListStyle = 1
- If Cells(TR, 6) = "城" Then
- .List = Sheets("系统设置").Range("A9:B36").Value
- .Height = 400
- .ColumnCount = 2
- .Width = 185
- .ColumnWidths = "130,10"
- Else
- .List = Sheets("系统设置").Range("C9:C35").Value
- .Height = 400
- .Width = 150
- .ColumnWidths = 130
- End If
- .Top = Target.Top
- .Left = Target.Left + Target.Width
- .Visible = True
- End With
- End If
-
- If TC = 8 Then
-
- ActiveWindow.ScrollRow = TR
- If Trim(Cells(TR, 7)) = "" Then
- Cells(TR, 7).Select
- Else
- With ListBox1
- .MultiSelect = 1
- .ListStyle = 1
- .List = Sheets("系统设置").Range("C9:C35").Value
- .Top = Target.Top
- .Left = Target.Left + Target.Width
- .Height = 400
- .Width = 150
- .ColumnWidths = 130
- .Visible = True
- End With
-
- If Trim(Target.Value) <> "" Then
- strV = Split(Target.Value, "、")
- For intI = 0 To UBound(strV)
- For intL = 0 To ListBox1.ListCount - 1
- If ListBox1.List(intL) = strV(intI) Then ListBox1.Selected(intL) = True
- Next
- Next
- End If
- End If
- End If
- ActiveWindow.ScrollRow = TR - 1
- ActiveWindow.ScrollRow = TR
- End If
- End Sub
复制代码 |
|