Consulting

Results 1 to 2 of 2

Thread: Determining how a ComboBox was changed ...

  1. #1
    VBAX Regular
    Joined
    Mar 2009
    Location
    Stowmarket
    Posts
    62
    Location

    Question Determining how a ComboBox was changed ...

    I have a ComboBox with a Change Event procedure associated with it.

    Is there any way, once I am directed into that procedure, that I can determine if the Change Event was triggered by a mouse selection from the drop-down list or by a key being pressed on the keyboard ?

  2. #2
    VBAX Contributor
    Joined
    May 2008
    Posts
    198
    Location
    Try something like this:
    [VBA]Private keyPressedByUser As Boolean
    Private Sub ComboBox1_Change()
    If keyPressedByUser Then
    MsgBox "Key pressed"
    keyPressedByUser = False
    End If
    End Sub
    Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    keyPressedByUser = True
    End Sub
    [/VBA]
    You'll may need to edit the KeyDown function to test which keys were pressed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •