Tab control from control to cell

J

JasonSelf

Lets get this out of the way...I am using the following for tabbing
between controls in my Excel sheet.
--------------------------------------------------------
Private Sub ComboBox103_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer)
Dim bBackwards As Boolean
Const ctlPrev As String = "ComboBox102"
Const ctlNext As String = "ComboBox104"

Select Case KeyCode
Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp
Application.ScreenUpdating = False
bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp)
If Application.Version < 9 Then Sheet1.Range("A1").Select
If bBackwards Then
Range(ctlPrev).Activate
Else
ActiveSheet.OLEObjects(ctlNext).Activate
End If
Application.ScreenUpdating = True
End Select
End Sub
-------------------------------------------------------
This is fine but what If I want the next Item to be a cell in the
document, lets say E22. How can I have it tab to that cell and then
get E22 to tab away to the next thing I want a tab in?

If that makes any sense I would appreciate the help.

Thanks as Always,
Jason Self
 
B

Bob Phillips

Jason ,

Just put the cell address in ctlPrev

Const ctlPrev As String = "E2"

Out of the way!

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

JasonSelf

I actually figured out just that not to long before you replied. I d
have the question though of once I have tabbed into that cell how I ca
convince VBA to let me tab out. In the event of a control object
would simply name the object.

Private Sub ComboBox102_KeyDown

how would I name this if it were refering to a specific cell like ou
E
 
B

Bob Phillips

I think you are out of luck. Shapes have a KeyDown event, but cells don 't .
Normal tabbing takes over from then on.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top