|
脑子有点转不过来,你自己测试下- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim arr(0 To 4), brr(0 To 4)
- If Target.Count > 1 Then Exit Sub
- If Target.Row < 7 Or Target.Row > 20 Then Exit Sub
- If Target.Column < 2 Or Target.Column > 18 Then Exit Sub
- If Target.Offset(-1, 0) = "" Then Exit Sub
- For i = 0 To 4
- If Target.Value + i > 9 Then
- arr(i) = Target.Value + i - 10
- Else
- arr(i) = Target.Value + i
- End If
- If Target.Value - i - 1 < 0 Then
- brr(i) = Target.Value - i + 9
- Else
- brr(i) = Target.Value - i - 1
- End If
- Next
- If Target.Offset(-1, 0).Value > Target.Value Then
- If Target.Offset(-1, 0).Value - Target.Value < 5 Then
- Sheet1.[ar1:ar5] = Application.WorksheetFunction.Transpose(arr)
- Sheet1.[aq1:aq5] = Application.WorksheetFunction.Transpose(brr)
- Else
- Sheet1.[ar1:ar5] = Application.WorksheetFunction.Transpose(brr)
- Sheet1.[aq1:aq5] = Application.WorksheetFunction.Transpose(arr)
- End If
- Else
- If Abs(Target.Offset(-1, 0).Value - Target.Value) < 5 Then
- Sheet1.[ar1:ar5] = Application.WorksheetFunction.Transpose(arr)
- Sheet1.[aq1:aq5] = Application.WorksheetFunction.Transpose(brr)
- Else
- Sheet1.[ar1:ar5] = Application.WorksheetFunction.Transpose(brr)
- Sheet1.[aq1:aq5] = Application.WorksheetFunction.Transpose(arr)
- End If
- End If
- End Sub
复制代码 |
|