Solved

Tab functionality in Excel

Posted on 2004-09-10
5
161 Views
Last Modified: 2010-05-02
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
Comment
Question by:corduroy9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:macaulish
ID: 12030646
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
 
LVL 2

Expert Comment

by:pittbb
ID: 12031204
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
 
LVL 81

Accepted Solution

by:
byundt earned 100 total points
ID: 12036733
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
 
LVL 2

Author Comment

by:corduroy9
ID: 12079168
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
 
LVL 81

Expert Comment

by:byundt
ID: 12079490
corduroy9,
Thanks for the grade!
Brad
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month5 days, 1 hour left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question