How to move from one control to another in a form on worksheet

How to move from one control to another in a form on worksheet

Dinesh Kumar Takyar

54 года назад

2,611 Просмотров

How to move from one control to another in a form on a worksheet using tab and shift keys coded with VBA. Here's the code for each control:
Private Sub cboItemName_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
Me.cboMfg.Activate
End If

End Sub

Private Sub cboMfg_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 0 And KeyCode = vbKeyTab Then
Me.txtBatchNo.Activate

ElseIf Shift = 1 And KeyCode = vbKeyTab Then
Me.cboItemName.Activate
End If

End Sub

Private Sub txtBatchNo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 0 And KeyCode = vbKeyTab Then
Me.txtExpiryDate.Activate
ElseIf Shift = 1 And KeyCode = vbKeyTab Then
Me.cboMfg.Activate
End If
End Sub

Private Sub txtExpiryDate_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 0 And KeyCode = vbKeyTab Then
Me.txtMRP.Activate
ElseIf Shift = 1 And KeyCode = vbKeyTab Then
Me.txtBatchNo.Activate
End If
End Sub

Private Sub txtMRP_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 0 And KeyCode = vbKeyTab Then
Me.txtPurchaseDate.Activate
ElseIf Shift = 1 And KeyCode = vbKeyTab Then
Me.txtExpiryDate.Activate
End If
End Sub

Private Sub txtPurchaseDate_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 0 And KeyCode = vbKeyTab Then
Me.txtQty.Activate
ElseIf Shift = 1 And KeyCode = vbKeyTab Then
Me.txtMRP.Activate
End If
End Sub

Private Sub txtQty_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 1 And KeyCode = vbKeyTab Then
Me.txtPurchaseDate.Activate
End If
End Sub
Details also available on our website: https://www.exceltrainingvideos.com/move-from-one-control-to-another-in-a-form-on-worksheet/

Тэги:

#how_to_move_from_one_control_to_another_in_a_form_on_worksheet #How_to_move_from_one_control_to_another_in_a_form_on_worksheet_using_tab_key #How_to_move_from_one_control_to_another_in_a_form_on_worksheetusing_tab_and_shift_keys #How_to_move_from_one_control_to_another_in_a_form_on_worksheet_using_vba #excel_vba_tutorial #excel_vba_for_beginners #excel_vba_for_advanced_learners #excel_vba_help #advanced_excel_vba #excel_vba_tutorials_for_beginners #excel_vba_advanced_tutorial
Ссылки и html тэги не поддерживаются


Комментарии: