Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In my workbook I have an "Employees" sheet. Column A is headed
'Payroll Number' and column B is 'Employee Name'. I then have a combobox in a userform which takes the Payroll Number from the Employees sheet. To the side of this combo box I have a text box to store the employee name. When I select a payroll number I need the employee name to be automatically populated in the employee name text box using a vlookup(?) from the "Employees" sheet. My VB skills are limited so looking for a solution if anyone can help please. Many thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Could you supply a cut down version of your workbook to save us having to reproduce your scenario? -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=143147 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Of course. File can be downloaded from http://sites.google.com/site/lucasreece/files.
Download issues.xls Clicking on the new issue command button opens the user form. Issue ID is automatically generated. Use the combo box to select an employee payroll number which is taken from the Empoyees sheet. When a payroll number has been selected, I need the name text box to display (using a lookup maybe?) the name for the selected payroll number from the Employees sheet. Hope that makes sense. Thanks. On 10 Oct, 21:40, p45cal wrote: Could you supply a cut down version of your workbook to save us having to reproduce your scenario? -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile:http://www.thecodecage.com/forumz/member.php?userid=558 View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=143147 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
UPDATE:
I've added this to the vba code... Private Sub cboPayrollNumber_Change() Me.txtName = WorksheetFunction.VLookup(Me.cboPayrollNumber, _ Worksheets("Employees").Range("A:D"), 4, 0) End Sub Now, when I click on the new issue button I get this... 'Run-time error: '1004': Unable to get the VLookup property of the WorksheetFunction class. Any ideas please? Need resolving quite urgently now if someone could help me out please. Thank you. On 10 Oct, 23:12, Lucas Reece wrote: Of course. File can be downloaded fromhttp://sites.google.com/site/lucasreece/files. Download issues.xls Clicking on the new issue command button opens the user form. Issue ID is automatically generated. Use the combo box to select an employee payroll number which is taken from the Empoyees sheet. When a payroll number has been selected, I need the name text box to display (using a lookup maybe?) the name for the selected payroll number from the Employees sheet. Hope that makes sense. Thanks. On 10 Oct, 21:40, p45cal wrote: Could you supply a cut down version of your workbook to save us having to reproduce your scenario? -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile:http://www.thecodecage.com/forumz/member.php?userid=558 View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=143147 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Add this change event code to cboPayrollNumber and every time you change the payrol number the employee name is added to the text box called txtName. Because you clear the combobox in the ADD button code we need on On Error statement. Note I convert the lookup to a value because the combobox is returning a string Private Sub cboPayrollNumber_Change() Dim LastRow As Long On Error Resume Next LastRow = Sheets("Employees").Cells(Cells.Rows.Count, "A").End(xlUp).Row txtName.Text = WorksheetFunction.VLookup(Val(cboPayrollNumber.Tex t), _ Sheets("Employees").Range("A2:B" & LastRow), 2, False) End Sub Mike "Lucas Reece" wrote: UPDATE: I've added this to the vba code... Private Sub cboPayrollNumber_Change() Me.txtName = WorksheetFunction.VLookup(Me.cboPayrollNumber, _ Worksheets("Employees").Range("A:D"), 4, 0) End Sub Now, when I click on the new issue button I get this... 'Run-time error: '1004': Unable to get the VLookup property of the WorksheetFunction class. Any ideas please? Need resolving quite urgently now if someone could help me out please. Thank you. On 10 Oct, 23:12, Lucas Reece wrote: Of course. File can be downloaded fromhttp://sites.google.com/site/lucasreece/files. Download issues.xls Clicking on the new issue command button opens the user form. Issue ID is automatically generated. Use the combo box to select an employee payroll number which is taken from the Empoyees sheet. When a payroll number has been selected, I need the name text box to display (using a lookup maybe?) the name for the selected payroll number from the Employees sheet. Hope that makes sense. Thanks. On 10 Oct, 21:40, p45cal wrote: Could you supply a cut down version of your workbook to save us having to reproduce your scenario? -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile:http://www.thecodecage.com/forumz/member.php?userid=558 View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=143147 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excellent! That worked. Thanks for that Mike.
However I now have another issue so hoping you can help if that's OK? When I click the Add button after creating a new issue, the message box is displayed saying issue complete which if fine but then when I click OK, I get a message box displayed saying "Invalid Property Value"! I've google this afternoon but can't seem to find a solution to this. Any ideas please? New file at http://sites.google.com/site/lucasreece/files. Download issues.xls Many thanks. On 11 Oct, 11:20, Mike H wrote: Hi, Add this change event code to cboPayrollNumber and every time you change the payrol number the employee name is added to the text box called txtName. Because you clear the combobox in the ADD button code we need on On Error statement. Note I convert the lookup to a value because the combobox is returning a string Private Sub cboPayrollNumber_Change() Dim LastRow As Long On Error Resume Next LastRow = Sheets("Employees").Cells(Cells.Rows.Count, "A").End(xlUp).Row txtName.Text = WorksheetFunction.VLookup(Val(cboPayrollNumber.Tex t), _ Sheets("Employees").Range("A2:B" & LastRow), 2, False) End Sub Mike "Lucas Reece" wrote: UPDATE: I've added this to the vba code... Private Sub cboPayrollNumber_Change() * * Me.txtName = WorksheetFunction.VLookup(Me.cboPayrollNumber, _ * * Worksheets("Employees").Range("A:D"), 4, 0) End Sub Now, when I click on the new issue button I get this... 'Run-time error: '1004': Unable to get the VLookup property of the WorksheetFunction class. Any ideas please? Need resolving quite urgently now if someone could help me out please. Thank you. On 10 Oct, 23:12, Lucas Reece wrote: Of course. File can be downloaded fromhttp://sites.google.com/site/lucasreece/files. Download issues.xls Clicking on the new issue command button opens the user form. Issue ID is automatically generated. Use the combo box to select an employee payroll number which is taken from the Empoyees sheet. When a payroll number has been selected, I need the name text box to display (using a lookup maybe?) the name for the selected payroll number from the Employees sheet. Hope that makes sense. Thanks. On 10 Oct, 21:40, p45cal wrote: Could you supply a cut down version of your workbook to save us having to reproduce your scenario? -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile:http://www.thecodecage.com/forumz/member.php?userid=558 View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=143147 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Date field in user form & Loading a user form on opening workbook | Excel Programming | |||
Automatically add a textbox to a user form based on user requireme | Excel Programming | |||
User Form Vlookup help? | Excel Programming | |||
Excel VB User Form Using Vlookup? | Excel Programming | |||
How to: User Form to assign a user defined range to a macro variab | Excel Programming |