F
Foxcole
I found this macro online for controlling tab order among unlocked
cells in a protected worksheet, and modified it to list the cells in
the tab order I need them, per instructions for the macro:
Private Sub Worksheet_Change(ByVal Target As Range)
'Anne Troy 's taborder event code
Dim aTabOrd As Variant
Dim i As Long
'Set the tab order of input cells
aTabOrd = Array("B1", "B3", "B4", "B5", "F1", "F3", "B10", "B12",
"E14", "B16", "F38", "A43", "A44", "A45", "A46", "A47", "A48", "A49",
"A50", "A51", "A52", "A53", "A54", "A55", "A56", "A57", "A58", "A59",
"A60", "F76", "F78")
'Loop through the array of cell address
For i = LBound(aTabOrd) To UBound(aTabOrd)
'If the cell that's changed is in the array
If aTabOrd(i) = Target.Address(0, 0) Then
'If the cell that's changed is the last in the array
If i = UBound(aTabOrd) Then
'Select first cell in the array
Me.Range(aTabOrd(LBound(aTabOrd))).Select
Else
'Select next cell in the array
Me.Range(aTabOrd(i + 1)).Select
End If
End If
Next i
End Sub
----
I have two problems.
The first is that this doesn't work reliably. Sometimes after I
unprotect and edit the sheet, protect it again and test it, it will
skip some cells entirely... and the cells it skips can be different
from one test to the next (but always skips the same set of cells
until after the next edit).
The other problem is that I need the macro to work whether or not a
change has been made in any of the cells, which could be different
each time the worksheet is used. This version doesn't do that, and I
am not trained in VBA. I used to be a programmer and can tell what the
macro is doing as I read through it, but have no idea what code I
would need to get it to do what I want.
cells in a protected worksheet, and modified it to list the cells in
the tab order I need them, per instructions for the macro:
Private Sub Worksheet_Change(ByVal Target As Range)
'Anne Troy 's taborder event code
Dim aTabOrd As Variant
Dim i As Long
'Set the tab order of input cells
aTabOrd = Array("B1", "B3", "B4", "B5", "F1", "F3", "B10", "B12",
"E14", "B16", "F38", "A43", "A44", "A45", "A46", "A47", "A48", "A49",
"A50", "A51", "A52", "A53", "A54", "A55", "A56", "A57", "A58", "A59",
"A60", "F76", "F78")
'Loop through the array of cell address
For i = LBound(aTabOrd) To UBound(aTabOrd)
'If the cell that's changed is in the array
If aTabOrd(i) = Target.Address(0, 0) Then
'If the cell that's changed is the last in the array
If i = UBound(aTabOrd) Then
'Select first cell in the array
Me.Range(aTabOrd(LBound(aTabOrd))).Select
Else
'Select next cell in the array
Me.Range(aTabOrd(i + 1)).Select
End If
End If
Next i
End Sub
----
I have two problems.
The first is that this doesn't work reliably. Sometimes after I
unprotect and edit the sheet, protect it again and test it, it will
skip some cells entirely... and the cells it skips can be different
from one test to the next (but always skips the same set of cells
until after the next edit).
The other problem is that I need the macro to work whether or not a
change has been made in any of the cells, which could be different
each time the worksheet is used. This version doesn't do that, and I
am not trained in VBA. I used to be a programmer and can tell what the
macro is doing as I read through it, but have no idea what code I
would need to get it to do what I want.