View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How can I activate a combobox by keyboard strokes ?

Lightly tested, but you could probably use the Keydown or Keyup event to
trigger your action - test for the enter key. Move your code out of the
click event.

Another consideration is how you get out of the Combobox. You need to do
that as well and the Keyup event can be used as well:

Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 13 Then
' your click event code
ActiveCell.Activate
End If

End Sub


--
Regards,
Tom Ogilvy



Oscar wrote in message
.nl...
Thanks Tom,

the keyword to focus the combobox was 'activate' as you mentioned.

However,
there is one problem,

When I push the arrow down button, the ComboBox_click() event is fired
immediately which calls the necessary processing routine. So I am not able
to scroll down the list to look for the specific item and then press at
RETURN. Is there a way to overcome this ?

regards,
Oscar





"Tom Ogilvy" schreef in bericht
...
I put this macro in a general module (in the VBE, Insert=Module)

Sub ActivateCombobo()
ActiveSheet.ComboBox1.Activate
End Sub

Then went back to Excel and in Tools=Macro=Macros, I selected it and
clicked the option button and but a lowercase b in for the short cut

key,
so
the short cut key is Ctrl+b


Then I could do Ctrl+B, Alt and down arrow do drop the list, (or use

just
the down arrow to go throught the list without droping the list), then

used
down and up arrow to scroll through the list and enter to make a

selection.

--
Regards,
Tom Ogilvy


Oscar wrote in message
.nl...
Tom,

the combobox was added by

choose bar 'Visual Basic'
select the control combobox with entry ability from the bar
draw the combobox at the sheet by making the sqaure with the mouse

press on 'edit modus' at the Visual Basic bar to edit the properties

of
the
combobox
the name of the bar is given 'ComboBox1' automatically.

Oscar






"Tom Ogilvy" schreef in bericht
...
What kind of comobox

Data validation (List option)
Dropdown box from the forms toolbar
Combobox from the control toolbox toolbar

--
Regards,
Tom Ogilvy

Oscar wrote in message
. nl...
I want to pull down a combo box that is within an Excel sheet and

select
an
item within the list by the keyboard instead of using the mouse

which
will
satisfy the user in case the user doesn't want to switch between
keyboard
and mouse all the time. How can I activate the combobox events

(such
as
dropdown and select an item by pressing return key) automatically

from
the
keyboard strokes or do I have to write my own procedures ?

Oscar