Hello, I have merged an existing form of mine with a template provided here: https://www.myonlinetraininghub.com/excel-forms-insert-update-delete
This is the integrated form on my one drive: https://1drv.ms/u/s!Ag-WnkpUjiS9iERfUB-SxbkNHayq
I am having an issue on 1 control however, and integrating a VLOOK up however.
If one has a list of staff names and corresponding employee numbers, how would a person have VLOOK up be performed against the selected staff names and have the employee number printed to the spreadsheet in Column F?
Also, depending on the value in the first combox box, which I have renamed to ‘GL’ how would I have another another V Look up print to the spreadsheet the corresponding department number?…
On another form I created this code worked but I cannot integrate it with yours:
Private Sub SaveData()
‘Save the data from the controls into current row
Dim C As MSForms.Control
Dim varValue As Variant ‘Must be variant to accept different types of data
For Each C In Me.Controls
If C.Tag “” Then
‘Get the value from the control
varValue = C.Value
Select Case C.Tag
Case “E”, “F”
‘These are a direct copy of their values to the worksheet
Worksheets(“Data”).Range(C.Tag & ThisRow.Row) = varValue
End Select
‘Insert Vlookup formula for the Employee Number
Worksheets(“Data”).Range(“E” & ThisRow.Row).FormulaR1C1 _
= “=IFERROR(VLOOKUP(RC[1],dropdown!C2:C3,2,FALSE),””””)”
Worksheets(“Data”).Range(“F” & ThisRow.Row).FormulaR1C1 = _
“=IF(ISNUMBER(SEARCH(“”Matthew””, RC[-2])),””Woodwork””, ” & _
“IF(ISNUMBER(SEARCH(“”Mark””, RC[-2])),””Paint””, ” & _
“IF(ISNUMBER(SEARCH(“”Luke””, RC[-2])),””Electrical””, ” & _
“IF(ISNUMBER(SEARCH(“”John””, RC[-2])),””Moulding””, ” & _
“IF(ISNUMBER(SEARCH(“”Jesus””, RC[-2])),””XXXX””, ” & _
“IF(ISNUMBER(SEARCH(“”Obama””, RC[-2])),””Metal””, ” & _
“IF(ISNUMBER(SEARCH(“”Trump””, RC[-2])),””xxxxx””, ” & _
“””””)))))))”
End If
Next C
Saved = True
End Suba
Also, for some strange reason, my 'Hours' control refuses to print to the spreadsheet...
Hi,
The line of code that writes Hours is disabled, uncomment it if you want it to write to table, see ModifyTableRow procedure.
For Employee number, I'm not seeing any source for this data. Add a new column "No" to the Employees table in Setup sheet with the missing employee numbers, and you can use a simple formula directly in the table, no need to search from code:
=INDEX(Employees[No],MATCH([@Employee],Employees[Employees],0))