Good afternoon,
I used the following tutorial to create a Multiple Selection ListBox Userform - Excel Easy - Multi ListBox Selection
I would like to update the following VBA code to be able to create each new line item in ListBox2 and the below dropdown & textboxes into individual rows. This code presently works on another of my userforms to add a single line of training to the table.
ListBox1 = List of all Employees
ListBox2 = Selection of bulk Employees
ComboBox1 = Training Event
TextBox1 = Training Date
ComboBox2 = Training Type
I used the following tutorial to create a Multiple Selection ListBox Userform - Excel Easy - Multi ListBox Selection
I would like to update the following VBA code to be able to create each new line item in ListBox2 and the below dropdown & textboxes into individual rows. This code presently works on another of my userforms to add a single line of training to the table.
ListBox1 = List of all Employees
ListBox2 = Selection of bulk Employees
ComboBox1 = Training Event
TextBox1 = Training Date
ComboBox2 = Training Type
VBA Code:
'Transfer Data to TrainingTrack tbl
Dim tbl As ListObject
Dim ws As Worksheet
Dim lrow As Range
Dim lrow2 As Long
Set tbl = Sheets("Training Tracker").ListObjects("TrainingTrack")
If tbl.ListRows.Count > 0 Then
Set lrow = tbl.ListRows(tbl.ListRows.Count).Range
For col = 1 To lrow.Columns.Count
If Trim(CStr(lrow.Cells(1, col).Value)) <> "" Then
tbl.ListRows.Add
Exit For
End If
Next
End If
lrow2 = tbl.ListRows.Count
tbl.DataBodyRange(lrow2, 1).Value = ComboBox1.Value
tbl.DataBodyRange(lrow2, 2).Value = Application.WorksheetFunction.Index(Sheets("Employee List").Range("D1:D1000"), Application.WorksheetFunction.Match(ComboBox1.Value, Sheets("Employee List").Range("K1:K1000"), 0))
tbl.DataBodyRange(lrow2, 3).Value = Application.WorksheetFunction.Index(Sheets("Employee List").Range("E1:E1000"), Application.WorksheetFunction.Match(ComboBox1.Value, Sheets("Employee List").Range("K1:K1000"), 0))
tbl.DataBodyRange(lrow2, 4).Value = Application.WorksheetFunction.Index(Sheets("Employee List").Range("C1:C1000"), Application.WorksheetFunction.Match(ComboBox1.Value, Sheets("Employee List").Range("K1:K1000"), 0))
tbl.DataBodyRange(lrow2, 5).Value = ComboBox2.Value
tbl.DataBodyRange(lrow2, 6).Value = TextBox1.Value
tbl.DataBodyRange(lrow2, 7).Value = TextBox2.Value
tbl.DataBodyRange(lrow2, 8).Value = ComboBox3.Value
tbl.DataBodyRange(lrow2, 9).Value = Application.WorksheetFunction.Index(Sheets("Employee List").Range("H1:H1000"), Application.WorksheetFunction.Match(ComboBox1.Value, Sheets("Employee List").Range("K1:K1000"), 0))
tbl.DataBodyRange(lrow2, 10).Value = Application.WorksheetFunction.Index(Sheets("Employee List").Range("J1:J1000"), Application.WorksheetFunction.Match(ComboBox1.Value, Sheets("Employee List").Range("K1:K1000"), 0))
tbl.DataBodyRange(lrow2, 11).Value = Worksheets("Dashboard").Range("C15").Value
tbl.DataBodyRange(lrow2, 12).Value = Now