Share via

VBA Code for custom Tab Order in Excel

Anonymous
2013-11-04T08:27:19+00:00

How can I create a custom tab order that is not contingent on a protected worksheet.  I have found the following code on-line but I am having some issues with the code.  For one it only advances via tab if I enter a change into a given cell.  Another problem is if I enter data inside a cell that is not listed in the code it gives an error message.  Any suggestions.

Private Sub Worksheet_Change(ByVal Target As Range) Dim aTabOrd As Variant Dim i As Long 'Set the tab order of input cells aTabOrd = Array("A5", "B5", "C5", "A10", "B10", "C10") '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

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-11-14T17:12:59+00:00

I posted the question in regard to VBA code for a custom tab order in Mr. Excel.  I received 2 very detailed answers, which I will have to take some time to see if I can get them to work in my program.  For those following this thread the link to their answers can be found at: http://www.mrexcel.com/forum/excel-questions/739188-visual-basic-applications-code-tab-order.html#post3633721

Was this answer helpful?

0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Jim G 134K Reputation points MVP Volunteer Moderator
    2013-11-10T17:45:57+00:00

    Your code does not seem to be Mac specific. You might want to post your question in the **Mr. Excel**forum for additional suggestions.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-11-06T16:13:26+00:00

    I didn't get an error code.  In fact the code given seems to work, ( although I am having some problems with cells duplicating after running the code).  My main problem is that the code only works to advance a cell if information is entered into the cell.    I have too many unprotected cells to use sheet protection to accomplish my task.  My ultimate goal is to have a custom tab order without using sheet protection; for example A1, F3, C8, etc...

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-11-05T23:55:00+00:00

    You state what you don't want (i.e., "only advances...changes in a given cell"), so in addition to knowing what error you're getting, it would be helpful to know what behavior you're expecting.

    Do you want those 6 cells to be the ONLY cells accessible? If not, what do you want to happen? If so, what should happen when the user clicks on a different cell?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-11-05T04:56:15+00:00

    What is the error message when you debug the code?

    Was this answer helpful?

    0 comments No comments