I have an existing workbook created to track/monitor customer service reports for approximately 90 employees, I'm trying to add a userform so that supervisors don't need to constantly change to the employees sheet to enter the data, I'd like the userform to do it for them.
I have the userform created and coded, it works just fine if I want it to go to a single sheet, but I'd like it to go to the correct employee's sheet. I know I'm over complicating this (I'm a beginner) but I don' know where/how to make it simpler. I'm using a combo box with all of the names.
Private Sub UserForm_Initialize()
'Fill CmboxEmployee
With EmployeeComboBox
.AddItem "Smith John"
.AddItem "Smith John2"
.AddItem "Smith John3"
.AddItem "Smith John4"
.AddItem "Smith John5"
.AddItem "Smith John6"
.AddItem "Smith John7"
.AddItem "Smith John8"
.AddItem "Smith John9"
.AddItem "Smith John10"
End With
End Sub
Private Sub CMDSubmit_Click()
Dim emptyRow As Long
'Make Employee Sheet active
If EmployeeComboBox.Value = "Smith, John" Then
ActiveWorkbook.Worksheets("Smith, John").Select
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
With Worksheet
.Cells(emptyRow, 2).Value = DTPicker1.Value
.Cells(emptyRow, 3).Value = AquaTextBox.Value
.Cells(emptyRow, 4).Value = CFSTextBox.Value
.Cells(emptyRow, 5).Value = NotesTextBox.Value
End With
End If
EmployeeComboBox.Value = ""
DTPicker1.Value = ""
AquaTextBox.Value = ""
CFSTextBox.Value = ""
NotesTextBox.Value = ""
End Sub
Private Sub ClearForm_Click()
Call UserForm_Initialize
End Sub
Private Sub CloseButton_Click()
Unload Me
End Sub
Thanks!
I have the userform created and coded, it works just fine if I want it to go to a single sheet, but I'd like it to go to the correct employee's sheet. I know I'm over complicating this (I'm a beginner) but I don' know where/how to make it simpler. I'm using a combo box with all of the names.
Private Sub UserForm_Initialize()
'Fill CmboxEmployee
With EmployeeComboBox
.AddItem "Smith John"
.AddItem "Smith John2"
.AddItem "Smith John3"
.AddItem "Smith John4"
.AddItem "Smith John5"
.AddItem "Smith John6"
.AddItem "Smith John7"
.AddItem "Smith John8"
.AddItem "Smith John9"
.AddItem "Smith John10"
End With
End Sub
Private Sub CMDSubmit_Click()
Dim emptyRow As Long
'Make Employee Sheet active
If EmployeeComboBox.Value = "Smith, John" Then
ActiveWorkbook.Worksheets("Smith, John").Select
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
With Worksheet
.Cells(emptyRow, 2).Value = DTPicker1.Value
.Cells(emptyRow, 3).Value = AquaTextBox.Value
.Cells(emptyRow, 4).Value = CFSTextBox.Value
.Cells(emptyRow, 5).Value = NotesTextBox.Value
End With
End If
EmployeeComboBox.Value = ""
DTPicker1.Value = ""
AquaTextBox.Value = ""
CFSTextBox.Value = ""
NotesTextBox.Value = ""
End Sub
Private Sub ClearForm_Click()
Call UserForm_Initialize
End Sub
Private Sub CloseButton_Click()
Unload Me
End Sub
Thanks!