Tab Sequence?

  • Thread starter Thread starter cornishbloke
  • Start date Start date
C

cornishbloke

tab sequence?
Is there a way to set the order in which cells are highlighted when
pressing the tab key?

i.e. I have a cell in which data is entered, and then a button which
fires a macro next to it. After entering the data I would like to be
able to tab out of the cell and have the button highlighted such that
pressing enter on the keyboard would trigger the button - much like a
web page.

Any suggestions?
 
I don't think you can do what you want. Excel allows for very
little control over the tab sequence of cells. Moreover, buttons
exists on a separate "layer" above that of the cells, so you
can't tab from the cells layer to the controls layer.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Cornishbloke,

I don't think you can do what you want to do. Whichever command button you
use, Forms or ActiveX Control, it won't automatically fire on the Enter key
(userform controls can, but they are the on ly things affected by tab in
that case). You need to click the button instead, which defeats your
purpose.

What you could so is get rid of the button, and have a worksheet event that
traps the input and then throws up an inputbox asking if they want to run
the macro, using enter as the default (I would use a userform myself as I
don't like inputbox). Here is an example

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sAns As String

Application.EnableEvents = True
On Error GoTo ws_exit
If Not Intersect(Target, Range("G10")) Is Nothing Then
sAns = InputBox("Do you wish to run the account macro?", , "Y")
If UCase(sAns) = "Y" Then
myAccountsMacro
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub

This is worksheet event code, so it goes into the appropriate worksheet code
module.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
tab sequence?
Is there a way to set the order in which cells are highlighted when
pressing the tab key?

Define Named Range MySTabOrder:
RefersTo:
=Sheet1!$E$15,Sheet1!$C$11,Sheet1!$E$8,Sheet1!$C$7

For what it's worth....
might be a start
 
Back
Top