Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Controlling tab order on a sheet to include AX combos

Try the following code in the Sheet code module for the sheet that contains
the Comboboxes. This will work with any number of comboboxes. The
TopLeftCell property of each control is tested against Target. If
TopLeftCell.Row = Target.Row AND (TopLeftCell.Column = Target.Column OR
TopLeftCell.Column = Target.Column -1) then drop down the combobox list set
set focus to the control.


Option Explicit

Private OLEObjs As Collection


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim OLEObj As OLEObject
'''''''''''''''''''''''''''''''''''''''''''
' If this is the first time through,
' load up the collection with Comboboxes.
'''''''''''''''''''''''''''''''''''''''''''
If OLEObjs Is Nothing Then
Set OLEObjs = New Collection
For Each OLEObj In Me.OLEObjects
If TypeOf OLEObj.Object Is MSForms.ComboBox Then
OLEObjs.Add Item:=OLEObj, key:=OLEObj.Name
End If
Next OLEObj
End If
'''''''''''''''''''''''''''''''''''''''''''''
' If more than one cell is selected, get out.
'''''''''''''''''''''''''''''''''''''''''''''
If Target.Cells.Count 1 Then
Exit Sub
End If
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
' Loop through the OLEObjs, and try to find one whose
' TopLeftCell is in the same rows as Target and
' TopLeftCell is in the same column or one column to
' the left of Target.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
For Each OLEObj In OLEObjs
With OLEObj.TopLeftCell
If .Row = Target.Row And _
(.Column = Target.Column Or .Column = Target.Column - 1) Then
''''''''''''''''''''''''''''''''''''''''''''''''
' We found the appropriate combobox. Drop down
' the list and set focus to the combobox.
''''''''''''''''''''''''''''''''''''''''''''''''
OLEObj.Object.DropDown
OLEObj.Verb xlVerbPrimary
Exit For
End If
End With
Next OLEObj
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"XP" wrote in message
...
I am using Office 2003 on Windows XP.

I have a sheet designed into a form in which certain cells are locked and
certain cells unlocked for completion, etc.

On this form there are some ActiveX combo boxes that I would like included
if the user tabs from cell to cell. Right now, the combo boxes are
ignored,
but I would like, say when the user tabs from a cell that preceeds a combo
box for the cursor to go to the combo box and open the drop down so the
user
can start typing or pick from the list.

1. Is this possible?

2. How can I make it work?

3. If possible can an example be posted?

4. Thanks sincerely in advance for your assistance.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Controlling tab order on a sheet to include AX combos

I had the column test backwards.

(.Column = Target.Column Or .Column = Target.Column - 1) Then

should be

(.Column = Target.Column Or .Column - 1 = Target.Column) Then


"Chip Pearson" wrote in message
...
Try the following code in the Sheet code module for the sheet that
contains the Comboboxes. This will work with any number of comboboxes.
The TopLeftCell property of each control is tested against Target. If
TopLeftCell.Row = Target.Row AND (TopLeftCell.Column = Target.Column OR
TopLeftCell.Column = Target.Column -1) then drop down the combobox list
set set focus to the control.


Option Explicit

Private OLEObjs As Collection


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim OLEObj As OLEObject
'''''''''''''''''''''''''''''''''''''''''''
' If this is the first time through,
' load up the collection with Comboboxes.
'''''''''''''''''''''''''''''''''''''''''''
If OLEObjs Is Nothing Then
Set OLEObjs = New Collection
For Each OLEObj In Me.OLEObjects
If TypeOf OLEObj.Object Is MSForms.ComboBox Then
OLEObjs.Add Item:=OLEObj, key:=OLEObj.Name
End If
Next OLEObj
End If
'''''''''''''''''''''''''''''''''''''''''''''
' If more than one cell is selected, get out.
'''''''''''''''''''''''''''''''''''''''''''''
If Target.Cells.Count 1 Then
Exit Sub
End If
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
' Loop through the OLEObjs, and try to find one whose
' TopLeftCell is in the same rows as Target and
' TopLeftCell is in the same column or one column to
' the left of Target.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
For Each OLEObj In OLEObjs
With OLEObj.TopLeftCell
If .Row = Target.Row And _
(.Column = Target.Column Or .Column = Target.Column - 1) Then
''''''''''''''''''''''''''''''''''''''''''''''''
' We found the appropriate combobox. Drop down
' the list and set focus to the combobox.
''''''''''''''''''''''''''''''''''''''''''''''''
OLEObj.Object.DropDown
OLEObj.Verb xlVerbPrimary
Exit For
End If
End With
Next OLEObj
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"XP" wrote in message
...
I am using Office 2003 on Windows XP.

I have a sheet designed into a form in which certain cells are locked and
certain cells unlocked for completion, etc.

On this form there are some ActiveX combo boxes that I would like
included
if the user tabs from cell to cell. Right now, the combo boxes are
ignored,
but I would like, say when the user tabs from a cell that preceeds a
combo
box for the cursor to go to the combo box and open the drop down so the
user
can start typing or pick from the list.

1. Is this possible?

2. How can I make it work?

3. If possible can an example be posted?

4. Thanks sincerely in advance for your assistance.





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
Creating and Controlling a User data Entry Sheet Crispy Excel Discussion (Misc queries) 0 June 2nd 06 11:11 AM
combos and dates Shorty[_3_] Excel Programming 7 March 2nd 06 04:22 PM
too many combos VOG Excel Programming 1 October 13th 05 05:31 PM
one sub for many Combos in different way jochynator Excel Programming 0 November 24th 04 11:45 PM
Controlling Tab order jpendegraft[_23_] Excel Programming 1 September 20th 04 08:49 PM


All times are GMT +1. The time now is 01:57 AM.

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"