+ Reply to Thread
Results 1 to 3 of 3

Use Up/Down Arrows as Tab/Shift+Tab in Userform

Hybrid View

lsteinbach Use Up/Down Arrows as... 07-10-2013, 04:12 PM
Leith Ross Re: Use Up/Down Arrows as... 07-10-2013, 04:24 PM
lsteinbach Re: Use Up/Down Arrows as... 07-10-2013, 04:54 PM
  1. #1
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Use Up/Down Arrows as Tab/Shift+Tab in Userform

    Hello,

    In my userform, I have about 20 textboxes that I need to rapidly cycle through to enter numbers then I press Enter to submit and cycle through the textboxes again (this repeats many, many times). This is most quickly done by using the up/down arrows and the keypad. But at the bottom of one column of textboxes, the down arrow will not carry to the next column of textboxes. I can tab to the next column since all the tab indexs are setup, but I will be able to move much faster if I can somehow set the down arrow key to be tab, then the up arrow key to be shift+tab.

    Any suggestions are very appreciated.
    Thank you!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Use Up/Down Arrows as Tab/Shift+Tab in Userform

    Hello lsteinbach,

    It can be done by SubClassing the TextBoxes on the UserForm. This will allow them to share a common event like KeyPress to identify the key that was pressed. If You don't want to use this method then the alternative is writing 20 different code events.

    To do the SubClassing, it would be helpful if can post your workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Use Up/Down Arrows as Tab/Shift+Tab in Userform

    Thank you for that hint. I was able to find the code I need and I realized I only need to apply it to the last textbox and first textbox in each column.
     
    Private Sub TextBox16_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
     ' 37 = left arrow, 38 = up arrow, 39 = right arrow, 40 = down arrow
     If KeyCode = 40 Then 'down key pressed
        Application.SendKeys "{TAB}"
     ElseIf KeyCode = 38 Then 'up key pressed
        Application.SendKeys "+{TAB}"
     End If
     End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1