Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 53
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 434
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 53
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 434
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control tab does not appear in format control dialogue box Phunky E Excel Discussion (Misc queries) 1 June 1st 07 04:05 PM
Control End Jaleel Excel Discussion (Misc queries) 3 September 23rd 06 04:34 PM
spinner format control has no control tab AJ Excel Worksheet Functions 4 March 5th 06 10:30 AM
control box ynissel Excel Discussion (Misc queries) 1 July 29th 05 05:14 PM
Control Tab from Combo box- format control missing!! Mo Excel Discussion (Misc queries) 3 January 7th 05 01:09 PM


All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"