Hi,
How can i set the tab order for worksheet activex controls as one would in a userform?
Thanks
Mohamed
Tab to an Activex Worksheet Control
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Tab to an Activex Worksheet Control
ActiveX controls on a worksheet don't have a tab order, so you have to write VBA code for the On Key Down event of each and every control, e.g.
In this example, the Tab key will cycle from TextBox1 to CheckBox1 to TextBox2 and back to TextBox1.
Code: Select all
Private Sub CheckBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
KeyCode = 0
Me.TextBox2.Activate
End If
End Sub
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
KeyCode = 0
Me.CheckBox1.Activate
End If
End Sub
Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
KeyCode = 0
Me.TextBox1.Activate
End If
End Sub
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 366
- Joined: 12 May 2010, 06:49
Re: Tab to an Activex Worksheet Control
Thanks again Hans for the instant reply.
Kind Regards
Mohamed
Kind Regards
Mohamed