So yeah, I'm incredibly new to the code world. I found some VBA Code on this sit for changing the tab order and it worked great! Except that tab order started working on all 6 of the worksheets instead of just the one I had intended. Which is annoying. I think it should be a simple fix. Just cannot figure it out. Any help or suggestions would be greatly appreciated! Here is the code that I currently have running:
In the ThisWorkBook Module...
In the Sheet Module "Customer Information"...
In a standard code module...
In the ThisWorkBook Module...
Code:
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
If ActiveSheet.Name = "Customer Information" Then SetOnkey True
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
SetOnkey False
End Sub
In the Sheet Module "Customer Information"...
Code:
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
If ActiveSheet.Name = "Customer Information" Then SetOnkey True
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
SetOnkey False
End Sub
In a standard code module...
Code:
Sub SetOnkey(ByVal state As Boolean)
If state Then
With Application
.OnKey "{TAB}", "'TabRange xlNext'"
.OnKey "~", "'TabRange xlNext'"
.OnKey "{RIGHT}", "'TabRange xlNext'"
.OnKey "{LEFT}", "'TabRange xlPrevious'"
.OnKey "{DOWN}", "do_nothing"
.OnKey "{UP}", "do_nothing"
End With
Else
'reset keys
With Application
.OnKey "{TAB}"
.OnKey "~"
.OnKey "{RIGHT}"
.OnKey "{LEFT}"
.OnKey "{DOWN}"
.OnKey "{UP}"
End With
End If
End Sub
Sub do_nothing()
'nothing to do
End Sub
Sub TabRange(Optional iDirection As Integer = xlNext)
Dim vTabOrder As Variant, m As Variant
Dim lItems As Long, iAdjust As Long
'--set the tab order of input cells - change ranges as required
vTabOrder = Array("B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10", "C3", "C4", "C5", "C6", "C7")
lItems = UBound(vTabOrder) - LBound(vTabOrder) + 1
On Error Resume Next
m = Application.Match(ActiveCell.Address(0, 0), vTabOrder, False)
On Error GoTo ExitSub
'--if activecell is not in Tab Order return to the first cell
If IsError(m) Then
m = 1
Else
'--get adjustment to index
iAdjust = IIf(iDirection = xlPrevious, -1, 1)
'--calculate new index wrapping around list
m = (m + lItems + iAdjust - 1) Mod lItems + 1
End If
'--select cell adjusting for Option Base 0 or 1
Application.EnableEvents = False
Range(vTabOrder(m + (LBound(vTabOrder) = 0))).Select
ExitSub:
Application.EnableEvents = True
End Sub