Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Navigating via tabbing on a worksheet

923 views
Skip to first unread message

pcw

unread,
Jun 6, 2003, 3:39:57 PM6/6/03
to

I want to be able to navigate from a radio button to
another via tabbing. Why is there no tab index on the
controls?

Putting a user form underneath the controls doesn't help
with what I want to do. I want to use the controls on a
worksheet so that they would appear seamless and part of
the worksheet.

I am using Excel 97.

Rob Bovey

unread,
Jun 6, 2003, 5:38:16 PM6/6/03
to
The TabOrder property is an inherited property. That means it comes from
the container that a control is situated in. A UserForm supplies this
property, a worksheet doesn't. You can still tab amongst controls on a
worksheet, you just have to code it yourself using each control's KeyDown
event procedure.

In the sample event procedure below I'll assume a hypothetical situation
where we have three textboxes: TextBoxPrevious, TextBoxCurrent, and
TextBoxNext. This event procedure shows you how to use VBA to emulate
tabbing behavior. Pressing Tab moves from TextBoxCurrent to TextBoxNext and
pressing Shift+Tab moves from TextBoxCurrent to TextBoxPrevious. The Up and
Down arrow keys and the Enter key are given similar behavior.

Private Sub TextBoxCurrent_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
Dim bBackwards As Boolean
Select Case KeyCode
''' These are the only keys we care about.
Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp
Application.ScreenUpdating = False
''' Determine if we need to move backwards.
bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp)
''' In Excel 97 we must select a cell before activating another
control.
Sheet1.Range("A1").Select
''' Activate the appropriate control based on key(s) pressed.
If bBackwards Then TextBoxPrevious.Activate Else
TextBoxNext.Activate
Application.ScreenUpdating = True
End Select
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"pcw" <peter.c...@a.statcan.ca> wrote in message
news:017101c32c63$68f90300$a601...@phx.gbl...

0 new messages