Set focus after tabbing through textboxes and checkboxes on sheet
Results 1 to 2 of 2

Thread: Set focus after tabbing through textboxes and checkboxes on sheet

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Set focus after tabbing through textboxes and checkboxes on sheet

    I have a sheet (not userform) with many ActiveX textboxes and checkboxes. It's used as a checklist for equipment inspections that gets printed out.

    Tabbing through the textboxes and checkboxes is hard coded on Sheet1 with:

    Code:
    Private Sub CheckBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
       If KeyCode = vbKeyTab Then
           CheckBox2.Activate
       End If
    End Sub
    My issue is when I get to row 30 or so, it keeps tabbing, but the screen view doesn't move with the tabbing. I've tried CheckBox2.SetFocus but I get errors.

    Code:
    Private Sub CheckBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
       If KeyCode = vbKeyTab Then
           CheckBox2.Activate
       End If
       CheckBox2.SetFocus
    End Sub
    tx

  2. #2
    MrExcel MVP
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    18,798
    Post Thanks / Like
    Mentioned
    34 Post(s)
    Tagged
    5 Thread(s)

    Default Re: Set focus after tabbing through textboxes and checkboxes on sheet

    Try...

    Code:
    Private Sub CheckBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
       If KeyCode = vbKeyTab Then
           With CheckBox2
                .Activate
                ActiveWindow.ScrollRow = .TopLeftCell.Row
           End With
       End If
    End Sub
    Hope this helps!
    Last edited by Domenic; Jul 17th, 2019 at 11:27 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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