#1   Report Post  
Junior Member
 
Posts: 1
Default Tab Order

Can anyone tell me what is wrong with this code? I believe it has something to do with the array. I had a similar sheet (with the same type of code) working, but when I changed the array it stopped working.

Public i As Integer

Private Sub Worksheet_selectionChange(ByVal Target As Range)
'Erik Van Geit
'050510 0044
'force user to tab in specific order = TabOrder
'selections within Taborder will be allowed else selection will jump to next
'problem when pressing "ENTER" an "allowed" cell is activated
'example (A1, C1, A2) change A1 == A2 is activated instead of C1
Dim TabOrder As Variant

Application.EnableEvents = False
TabOrder = Array("j1", "j2", "e4", "d5", "b11", "b12", "b13", "b14", "b15", "b16", "b17", "b18", "b19", "b20", "b21", "b22", "b23", "c23", "b27", "b28", "b29", "b30", "b31", "f34", "f36", "f38", "d39", "d40", "d41", "e43", "e44", "d46", "d47", "d50", "d51", "b55", "b56", "b57", "i9", "g12", "g13", "g14", "g15", "i18", "g21", "k26", "k28", "h36", "i36", "h37", "i37", "h38", "i38", "h45", "i45", "k45", "h46", "i46", "k46", "h47", "i47", "k47", "k56", "k58", "l58", "k60", "l60")

On Error Resume Next
ref = Application.Match(Target.Address(0, 0), TabOrder, 0)
On Error GoTo 0

If IsError(ref) Then
If i = UBound(TabOrder) Then i = 0 Else i = i + 1
Me.Range(TabOrder(i)).Select
Else
i = ref - 1
If ref < 0 Then ref = UBound(TabOrder)
End If

Application.EnableEvents = True
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is the order of my data table opposite from graph? mozermodo Charts and Charting in Excel 6 April 25th 23 03:43 AM
How to change Series order in a Combination Chart? vrk1 Charts and Charting in Excel 3 April 1st 05 07:21 AM
How to change Series Order in a Combination Chart? vrk1 Excel Discussion (Misc queries) 0 March 31st 05 11:19 PM
purchase order counter in excel purchase order template Brandy@baoco Excel Worksheet Functions 0 February 23rd 05 06:17 PM
Maintaining a default worksheet order Graham Excel Discussion (Misc queries) 4 February 21st 05 08:52 PM


All times are GMT +1. The time now is 05:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"