1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Public Rg As Range
Public r As Integer
Public c As Integer
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Set Rg = Target
r = 0
c = 1
End Sub
'
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Not Rg Is Nothing Then
If Not Application.Intersect(Target, Range(Rg, Rg.Offset(1, 1))) Is Nothing Then
Application.EnableEvents = False
Set Rg = Rg.Offset(r, c)
Rg.Select
If r = 0 Then r = 1 Else r = 0
If r = 0 Then c = 1 Else c = -1
Application.EnableEvents = True
Else
Set Rg = Nothing
End If
End If
End Sub |
Partager