Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Tab to next control box
I've added a few control boxes to a spreadsheet and created some related
macros and links to data, without going through VB and first creating a user form. 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. Can this setup be done without having first created a user form? Can a user form be created after the setting up control boxes? -- TASR |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Tab to next control box
Works well, Hector, thanks so much. In general, is it more beneficial/worth
the time to create user forms in Visual Basic? -- TASR "Héctor Miguel" wrote: 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 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Tab to next control box
hi, Tiffany !
Works well, Hector, thanks so much. In general, is it more beneficial/worth the time to create user forms in Visual Basic? glad it worked for you ;) AFAIK, there is no a general *better way* to do something (but)... if you need to use/embed several controls in worksheets... it is generally recommended to move them and use/design userforms (you will preserve your workbooks integrity as far as you can) regards, hector. __ previous __ 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Control tab does not appear in format control dialogue box | Excel Discussion (Misc queries) | |||
Control End | Excel Discussion (Misc queries) | |||
spinner format control has no control tab | Excel Worksheet Functions | |||
control box | Excel Discussion (Misc queries) | |||
Control Tab from Combo box- format control missing!! | Excel Discussion (Misc queries) |