Results 1 to 3 of 3

Thread: [RESOLVED] Macro option shortcut key fails in Combobox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2011
    Posts
    26

    Resolved [RESOLVED] Macro option shortcut key fails in Combobox

    I have two columns, the A column w/ a combobox populates the B column with info from a named list. There is a macro button with an option shortcut to run it = "Ctrl + F" to print the page. This shortcut function "Ctrl+F" works to print when any of the page is selected except the combobox.

    I would like to be able to type in text in that combobox and not have to select another cell before using the "Ctrl+F" function to print. The "Ctrl+F" needs to work while typing selections inside the combobox. Is this possible?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Macro option shortcut key fails in Combobox

    try like this, where hhd is the name of the procedure you want to run
    vb Code:
    1. Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    2. If KeyCode = vbKeyF And Shift = 2 Then hhd
    3. End Sub
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2011
    Posts
    26

    Re: Macro option shortcut key fails in Combobox

    Well, thanks again Pete. I had a little issue but I'm catching on just a bit. Here's another section I had:
    Code:
    'Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'If KeyCode = vbKeyF And Shift = 2 Then PrintARX1
    'End Sub
    
    Private Sub TempCombo_KeyDown(ByVal _
            KeyCode As MSForms.ReturnInteger, _
            ByVal Shift As Integer)
            If KeyCode = vbKeyF And Shift = 2 Then PrintARX1
            If KeyCode = vbKeyR And Shift = 2 Then ClearForm
        
        Select Case KeyCode
            Case 9
                ActiveCell.Offset(0, 1).Activate
            Case 13
                ActiveCell.Offset(1, 0).Activate
            Case Else
        End Select
    
    End Sub
    I had another code piece w/ a different name using my combobox, so it didn't work until I inserted the correct portion from yours underneath that. That might seem intuitive to you, but I didn't get it at first. A little rearranging and correct name typing gave me what I needed, and it works for both functions. I'm kinda proud of myself that I figured that part out, even though this must be so basic to most in here!! This must have been much less painful than the last bit of help for me, eh? I have another question related to this but I guess I should start a new thread if I understand the rules right.

    Thanks again.

Posting Permissions

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



Click Here to Expand Forum to Full Width