ok so I have been racking my head against the wall to try and figure this out. I have a userform that when the user clicks the ok button. I need to get this to perform a vlookup the value from a combobox in sheet "Employee Data" in range B4:B49. It needs to return the value in column 3. But if 1 of the 4 Option buttons has been clicked then it needs to return the value specified. Right now I have it entering the data in the last row available. Attached is the code that works. Everything except for this lookup function. Honestly I'm not sure how to write this part.
Thanks in advance
Excel 2016
Code:
Private Sub CommandButton2_Click()
Dim sday As String, f As Range, fa As Range, fb As Range, fc As Range, fd As Range, fe As Range, Cl As Range, rng As Range, lr As Long, sh As Worksheet, Dic As Object
ActiveSheet.Unprotect Password:=""
Set sh = ActiveSheet
Set wsLookup = ("Employee Data")
Set f = sh.Range("A:A").Find(cboEmployee, , xlValues, xlWhole)
Set fa = sh.Range("A:A").Find(cboEmployee2, , xlValues, xlWhole)
Set fb = sh.Range("A:A").Find(cboEmployee3, , xlValues, xlWhole)
Set fc = sh.Range("A:A").Find(cboEmployee4, , xlValues, xlWhole)
Set fd = sh.Range("A:A").Find(cboEmployee5, , xlValues, xlWhole)
Set fe = sh.Range("A:A").Find(cboEmployee6, , xlValues, xlWhole)
If Not f Is Nothing Then
lr = f.Row
Do While sh.Cells(lr, "C") <> ""
lr = lr + 1
Loop
sh.Cells(lr, "C").Value = TextBox1.Value
sh.Cells(lr, "D").Value = TextBox2.Value
sh.Cells(lr, "H").Value = TextBox3.Value
sh.Cells(lr, "I").Value = TextBox4.Value
sh.Cells(lr, "B").Value = WorksheetFunction.VLookup(cboEmployee.Value(Sheets("Employee Data").Range("B4:B49"), 3,False)
'Inputs different department # if changed
If OptionButton1.Value = True Then
sh.Cells(lr, "B").Value = ("300")
End If
If OptionButton2.Value = True Then
sh.Cells(lr, "B").Value = ("325")
End If
If OptionButton3.Value = True Then
sh.Cells(lr, "B").Value = ("350")
End If
If OptionButton4.Value = True Then
sh.Cells(lr, "B").Value = ("360")
End If
End If
Thanks in advance
Excel 2016