How can I send SendKeys command to KeyUp event?

korhan

Board Regular
Joined
Nov 6, 2009
Messages
215
Hello forum rats,
I have certain event that is linked to an ActiveX combo box.
Code:
Public Sub ComboBox2_KeyUp(ByVal keyCode As MSForms.ReturnInteger, ByVal shift As Integer)
    ' Check if the user is pressing up or down arrow key, if yes run the macro
    If keyCode = 38 Or keyCode = 40 Or keyCode = 13 Then
        Call ComboBox2_Click
    End If
End Sub

I would like to send down arrow key up or down event to this event handler every 10 seconds so that it increases the item index in the combobox and I can just sit back and watch 'till it reaches to the very last item in the combobox.

Is there a way to this?
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi,

You could try something like this:
Code:
Sub Timer()
    Static Index As Long
    ComboBox1.ListIndex = Index
    ComboBox1.DropDown
    Index = Index + 1
    Application.OnTime Now + TimeValue("00:00:01"), "Sheet1.Timer"
End Sub
The code needs to be pasted into the code module for Sheet1 and Sheet1 also need to contain ComboBox1.
Note: It just crashes when it gets to the end of the list.

Regards,
 
Upvote 0
Rick,
I have tried a similar method and it works but I am just curious to see how I can actually send a sendkey value as an argument to the keyup function parameter.
I just cannot find the data type for ByVal keyCode As MSForms.ReturnInteger. This is definitely not an integer.
Thanks.
 
Upvote 0

Forum statistics

Threads
1,216,146
Messages
6,129,134
Members
449,488
Latest member
qh017

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top