I cannot thank this board enough! This is my first major post/request. (Many thanks to Rick and AlphaFrog for their contributions to this)
So, I have a userform to record very simple payroll data. The user selects a worker (individual), work performed, and then enters a quantity (hours/pieces) and clicks SUBMIT. The data then gets sent to the matching 'job' worksheet, finds the workers name in column A and places the quantity in the next empty column.
The user can only select ONE worker at a time using a combobox. The combobox pulls in worker names from a list defined in one of the worksheets.
My question: Is it possible for the user to select multiple workers? Since many workers work on the same job at a time, it would be easier to be able to select as many workers worked on that same job. The quantity would be the same. I'm just having a rough time figuring out how to manipulate the VBA to accomplish this if I use checkboxes and how it would populate from the 'names' list. Here is an image of my userform and workbook, code for SUBMIT is below.
So, I have a userform to record very simple payroll data. The user selects a worker (individual), work performed, and then enters a quantity (hours/pieces) and clicks SUBMIT. The data then gets sent to the matching 'job' worksheet, finds the workers name in column A and places the quantity in the next empty column.
The user can only select ONE worker at a time using a combobox. The combobox pulls in worker names from a list defined in one of the worksheets.
My question: Is it possible for the user to select multiple workers? Since many workers work on the same job at a time, it would be easier to be able to select as many workers worked on that same job. The quantity would be the same. I'm just having a rough time figuring out how to manipulate the VBA to accomplish this if I use checkboxes and how it would populate from the 'names' list. Here is an image of my userform and workbook, code for SUBMIT is below.
Code:
Private Sub CommandButton1_Click()
Dim Found As Range
'If statements check which worksheet to activate and, thus, send data to
If ComboBox2.Value = "Bites" Then
Worksheets("ThorLab Bites").Activate
ElseIf ComboBox2.Value = "Cleaning" Then
Worksheets("Cleaning").Activate
ElseIf ComboBox2.Value = "Boxes" Then
Worksheets("ThorLab Boxes").Activate
ElseIf ComboBox2.Value = "Snacks" Then
Worksheets("ThorLab Snacks").Activate
ElseIf ComboBox2.Value = "Shredding" Then
Worksheets("Shredding").Activate
ElseIf ComboBox2.Value = "Global" Then
Worksheets("Global").Activate
ElseIf ComboBox2.Value = "Gloves" Then
Worksheets("Gloves").Activate
ElseIf ComboBox2.Value = "Laundry" Then
Worksheets("Laundry").Activate
End If
'finds matching name, then sends data to the right side in the nearest empty cell
If Me.TextBox3.Value = "" Then
MsgBox "Nothing entered ", , "Missing Entry"
Else
Set Found = ActiveSheet.Range("A:A").Find(What:=Me.ComboBox1.Value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Found Is Nothing Then
MsgBox "No match for " & Me.ComboBox2.Value, , "No Match Found"
ElseIf MsgBox("You are about to submit the following pieces/hours for " & Me.ComboBox1.Value & ": " & Me.TextBox3.Value & vbNewLine & vbNewLine & "Is this correct?", vbYesNo, "Is this correct?") = vbNo Then Exit Sub
Else
ActiveSheet.Cells(Found.Row, Columns.Count).End(xlToLeft).Offset(, 1).Value = Me.TextBox3.Value
End If
End If
Call UserForm_Initialize
End Sub