Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Tab functionality in Excel

I have a custom application developed in Excel using VBA and macros.  Users will be doing data entry using this template.  I would like to automate the cell location following a tab out of a specific column.  Is there a way to capture the tab event only for a specific column?
0
corduroy9
Asked:
corduroy9
1 Solution
 
macaulishCommented:
What exactly are you trying to do?  I don’t think there’s a way to trap the tab key event but I may be able to devise a workaround if I know more details.
0
 
pittbbCommented:
You don't need to use any code at all in Excel 11.  (What version of excel are you using?).  Unlock whatever cells you want to be tab stops.  (cntrl + 1 - protection tab - uncheck "locked").  Then from tools - protection - protect sheet - allow all users of this worksheet to... - uncheck "Select locked cells."  Then the tabs should only go to the cells that you unlocked.  The are all locked by default - which does nothing unless the protection is turned on.  I believe this will give you the functionality you are looking for.  Not sure if the menus, functionality, etc is the same in previous versions, but if the funcitonality is there (I think it is), it would be a similar set of steps.

Hope this helps...
0
 
byundtCommented:
You can trap the tab key using the Application.OnKey method. Here are some subs that go into the code pane for the worksheet for this purpose. When Sheet1 is activated, the tab key is trapped by the TabNext sub. If the active cell is in column A, then the Select Case determines which cell to go to next. When Sheet1 is deactivated, the tab key is restored to its normal function.

Private Sub Worksheet_Activate()
Application.OnKey "{TAB}", "Sheet1.TabNext"    'Trap the tab key when this worksheet is active
End Sub

Private Sub Worksheet_Deactivate()
Application.OnKey "{TAB}", ""   'Restore default action of tab key when sheet deactivated
End Sub

Sub TabNext()
If Intersect(ActiveCell, Columns("A")) Is Nothing Then Exit Sub
Select Case ActiveCell.Row  'Create the Tab order as follows
Case 2
    Range("A5").Select
Case 5
    Range("A8").Select
Case 8
    Range("A2").Select
End Select
End Sub
0
 
corduroy9Author Commented:
Sorry this took so long - I've been traveling.

Thanks Bryundt - that seems to be working for me!  Pittbb, that solution may work as well, but the programmatic solution is really what I was looking for.  
0
 
byundtCommented:
corduroy9,
Thanks for the grade!
Brad
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now