Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
CellTab Target.Offset(0, -1), True
End Sub
Sub CellTab(ByVal Target As Range, Optional T1 As Boolean)
Dim TabOrder As Variant
Dim i As Long, T2 As Boolean
If T1 = False And T2 = False Then
Application.EnableEvents = True
Exit Sub
End If
T1 = False
TabOrder = Array("B3", "C3", "D3", "B4", "C4", "D4", "B5", "C5", "D5")
For i = LBound(TabOrder) To UBound(TabOrder)
If TabOrder(i) = Target.Address(0, 0) Then
If i = UBound(TabOrder) Then
Range(TabOrder(LBound(TabOrder))).Select
T2 = True
Else
Application.EnableEvents = False
Range(TabOrder(i + 1)).Select
T2 = False
Exit For
End If
End If
Next i
CellTab Target
End Sub
[color="#0000ff"]楼主利用数组保存单元格移动顺序,进而控件单元格的移动,是新颖的思路-taller
[此贴子已经被taller于2005-7-23 11:55:14编辑过] |