VBA Hack 2: ActiveX Objects Tab Order


Programming tab order from field 1 to field 2 
[TIP] The first post of 2017 has gotten to be what I work most with in 2016, Visual Advanced Basic. An extremely useful programming for automation in offices. Of which, forms are useful when inputting data into spreadsheets.

Technically, there are two forms controls in Microsoft EXCEL, ActiveX and not. In this post, I am referring to ActiveX. It is also possible to setup the latter but not without VBA codes, hence when it comes to forms controls in the spreadsheet, ActiveX controls offers more control.

So here it is, the codes that move the cursor from field 1 to field 2 in the example above when the user press tab while the cursor is in field 1.    

Private Sub cb1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      If KeyCode = 9 Then cb2.Activate
End Sub
 Where cb1 is the name of field one.
Next PostNewer Post Previous PostOlder Post Home