Columnbound?

  • Thread starter Thread starter rahul25
  • Start date Start date
R

rahul25

I created a multipage userform in excel VBA.

userform Page 1 for info data entry
excel sheet sample below

A B C D
Name Age case# file#
1 Mr. x 27 2345 5677
2 Ms. Y 49 2356 5678

userform Page 2 for number of hours worked entry:

Name <Combobox stating row source>
Age <label 1>
Case# <label2>
File# <label3>
Hours < will type in>

My question is , if I select a name in combobox in userform page 2 ,
how it is possible to display corresponding data in label 1 , label 2
and label 2 automatically.

Please help.
 
Assuming data on Sheet2 try something like:

Private Sub cmbName_Change()
Dim fndName As Range
With Sheets(2).Columns(1) '<<change as required
Set fndName = .Find(Me.cmbName.Value)
End With
If Not fndName Is Nothing Then
Me.lblAge.Caption = fndName.Offset(0, 1).Value
Me.lblCase.Caption = fndName.Offset(0, 2).Value
Me.lblFile.Caption = fndName.Offset(0, 3).Value
End If
DoEvents
End Sub

Hope this helps
Rowan
 

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