I have 35 Rows of data in a Worksheet
The worksheet is protected
I have several cells that I need to land on when the user presses the tab key - these cells are formatted as unprotected
The last 2 cells in each row are formatted as unprotected - but I don't want to stop on them when using TAB Key
The last 2 cells in each row - I want to skip when using TAB and wrap the selection around to the first unprotected cell in the next row
I have the "TAB Control" code below in "Worksheet1(Code)" - This code works but only for the 1st and 2nd rows (TAB,TAB,SKIP IC, SKIP ID, Wraparound to next row)
Once I hit Row 3 - the entire sub seems to stop working and once again TAB will Stop and Select both IC & ID
Any help or insight you could provide would be appreciated
Private Sub Worksheet_Change(ByVal Target As Range)
Static sRg As Range
Dim ColumnOffset As Integer
'------------------------------------------------------------
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Union([IC:IC], [ID:ID])) Is Nothing Then
With Target
Application.EnableEvents = False
If Not sRg Is Nothing Then
If sRg.Column < .Column Then
ColumnOffset = 1
ElseIf .Column <> 1 Then
ColumnOffset = -1
End If
Else
ColumnOffset = 1
End If
.Offset(, ColumnOffset).Select
Application.EnableEvents = True
End With
End If
Set sRg = ActiveCell
End Sub
The worksheet is protected
I have several cells that I need to land on when the user presses the tab key - these cells are formatted as unprotected
The last 2 cells in each row are formatted as unprotected - but I don't want to stop on them when using TAB Key
The last 2 cells in each row - I want to skip when using TAB and wrap the selection around to the first unprotected cell in the next row
I have the "TAB Control" code below in "Worksheet1(Code)" - This code works but only for the 1st and 2nd rows (TAB,TAB,SKIP IC, SKIP ID, Wraparound to next row)
Once I hit Row 3 - the entire sub seems to stop working and once again TAB will Stop and Select both IC & ID
Any help or insight you could provide would be appreciated
Private Sub Worksheet_Change(ByVal Target As Range)
Static sRg As Range
Dim ColumnOffset As Integer
'------------------------------------------------------------
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Union([IC:IC], [ID:ID])) Is Nothing Then
With Target
Application.EnableEvents = False
If Not sRg Is Nothing Then
If sRg.Column < .Column Then
ColumnOffset = 1
ElseIf .Column <> 1 Then
ColumnOffset = -1
End If
Else
ColumnOffset = 1
End If
.Offset(, ColumnOffset).Select
Application.EnableEvents = True
End With
End If
Set sRg = ActiveCell
End Sub