Tab to next control box
hi, Tiffany !
I've added a few control boxes to a spreadsheet and created some related macros and links to data ...
I can't seem to find a way to allow the user to tab from one control box to the next as data is to be entered ...
assuming embedded controls a 'TextBox1', 'TextBox2' y 'TextBox3'
following lines will activete from active textbox to next - using {tab} <-
[or... if user press {shift} + {tab} will activate previous]
[if there is NO next or previous... focus goes back to worksheet active selection]
if any doubt [or further information]... would you please comment ?
regards,
hector.
=== in 'that' worksheet code module ===
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyReturn Then SendKeys "{esc}"
If KeyCode = vbKeyTab Then
If Shift = 0 Then OLEObjects("textbox2").Activate Else SendKeys "{esc}"
End If
End Sub
Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyReturn Then SendKeys "{esc}"
If KeyCode = vbKeyTab Then
If Shift = 0 Then OLEObjects("textbox3").Activate Else OLEObjects("textbox1").Activate
End If
End Sub
Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyReturn Then SendKeys "{esc}"
If KeyCode = vbKeyTab Then
If Shift = 1 Then OLEObjects("textbox2").Activate Else SendKeys "{esc}"
End If
End Sub
|