Combo box to display in label

anthonfire

New Member
Joined
Oct 9, 2006
Messages
3
Hi im doing a payroll program and i need to get a label to display the payrate for people listed in the combo box. Both the payrate and employee name are linked from the excel sheet. So when a different name is selected from the list the label changes the payrate. Any ideas?

cheers
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

neilp

Well-known Member
Joined
Jul 5, 2004
Messages
515
Hi Anthonfire

Welcome to the board

what column is the employee name in, and what column is the payrate in?
I assume you are using a userform

N
 

anthonfire

New Member
Joined
Oct 9, 2006
Messages
3
VBA Code

Thanks for the reply.
The employee name is b and colmn h for the payrate.

Cheers
 

neilp

Well-known Member
Joined
Jul 5, 2004
Messages
515
Code:
Private Sub ComboBox1_Change()
    Label1.Caption = Range(ComboBox1.RowSource).Offset(0, 6).Cells(ComboBox1.ListIndex + 1)
    End Sub

If you are using a userform, paste in this code and it will hopefully work (untested)

n
 

anthonfire

New Member
Joined
Oct 9, 2006
Messages
3

ADVERTISEMENT

tried it

Thanks for that.
I tried

Private Sub cboEmployeeName_Change()
lblPayRate.Caption = Range(cboEmployeeName.RowSource).Offset(0, -1).Cells(cboEmployeeName.ListIndex + 6)

It didnt work, I may have done it wrong. Could i send it to you and you could have a look?

Appreciate the help.
 

deangla

New Member
Joined
Oct 1, 2006
Messages
6

ADVERTISEMENT

Neil,

I'd be interested in how this was resolved. I've been playing with something close to this.

I'd appreciate it.

Thanks,

Dean
 

neilp

Well-known Member
Joined
Jul 5, 2004
Messages
515
Hi Dean

the code I posted did the job - the problem was that the combobox was being populated not using the rowsource property. Once that was altered it seemed to be working ok

N
 

deangla

New Member
Joined
Oct 1, 2006
Messages
6
Thanks Anthony and Neil for your responses. This is extremely helpful. Saves me a lot of hair. :biggrin: Have a nice day.

Dean
 

Forum statistics

Threads
1,141,627
Messages
5,707,495
Members
421,511
Latest member
mgroah1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top