Set focus after tabbing through textboxes and checkboxes on sheet

thequickness

New Member
Joined
Jul 17, 2019
Messages
10
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
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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:
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,211
Members
448,554
Latest member
Gleisner2

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