Help

  • Thread starter Thread starter Mfadli
  • Start date Start date
M

Mfadli

Hi,

I have one problem in create a data in userform.

The problem is:


1) I want to type the staff ID and the name will appear. I try to use
function "If" but its limited to 64 k only for every function. I also
use vlookup and link to the sheet. But still have a error. Please
guide me. Thank You

Example:

Staff Id : 010035
Name : Automitacally appear when i type a staff Id
(this scenario in user form, not in sheet)

Can anybody provide the code
 
I have one problem in create a data in userform.

The problem is:


1) I want to type the staff ID and the name will appear. I try to use
function "If" but its limited to 64 k only for every function. I also
use vlookup and link to the sheet. But still have a error. Please
guide me. Thank You

Example:

Staff Id : 010035
Name : Automitacally appear when i type a staff Id
(this scenario in user form, not in sheet)

Can anybody provide the code

Hi

Assuming that you have a sheet named "Staff" where you have staff ID and
name in column A and B.
The trick is to use the "VAL()" function.

Try this code:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ID = Val(Me.TextBox1.Value)
tsheet = ActiveSheet.Name
rSheet = "Staff"
Sheets(rSheet).Select
startcell = "A2"
Lastcell = Range(startcell).End(xlDown).Address
Range(startcell).Select
For Each c In Range(startcell, Lastcell)
If ID = c Then
Me.TextBox2.Value = ActiveCell.Offset(0, 1).Value
End
End If
ActiveCell.Offset(1, 0).Select
Next
Sheets(tsheet).Activate
End Sub

Sincerly,

Per
 

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