Assigning a sub to a specific keybordkey

  • Thread starter Thread starter PO
  • Start date Start date
P

PO

Hi!

I have a userform in Excel (version 2000) which has a textbox (txtInvoice)
and a listbox (lstInvoices).

When the user, after typing the invoicenumber into the textbox, presses the
Enter-key (on the numerical keypad) the number should be added to the
listbox.
How do I assign the sub that does the transfer to the Enter-key?

TIA
PO
 
PO said:
Hi!

I have a userform in Excel (version 2000) which has a textbox (txtInvoice)
and a listbox (lstInvoices).

When the user, after typing the invoicenumber into the textbox, presses the
Enter-key (on the numerical keypad) the number should be added to the
listbox.
How do I assign the sub that does the transfer to the Enter-key?

TIA
PO

PO Try this..

'''' After user enter info they press Tab or Return key the if
statement will evaluate which key and proceed''''

Private Sub txtInvoice_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,
ByVal Shift As Integer) 'tab key



If KeyCode = "9" Or KeyCode = "13" Then
''''''''Your code goes here''''''
End If
End Sub

HTH

Charles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top