Ok, the form looks like this. It is the last section combo box
form.PNG
section4.PNG
The code is:
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 "A", "C", "G", "H", "I", "J", "M", "P", "S"
'These are a direct copy of their values to the worksheet
Worksheets("Data").Range(C.Tag & ThisRow.Row) = varValue
Case "K", "L", "N", "O", "Q", "R", "T", "U"
If WorksheetFunction.IsText(C.Tag) Then 'Tests if "Complete" selected from DropDown
Worksheets("Data").Range(C.Tag & ThisRow.Row) = varValue
Else
'If not text thenthis value is a double number so convert text number to double number
Worksheets("Data").Range(C.Tag & ThisRow.Row) = CDbl(varValue)
End If
Case "B", "D"
'These values must be valid dates so convert text date to date value
If IsDate(varValue) Then
Worksheets("Data").Range(C.Tag & ThisRow.Row) = CDate(varValue)
End If
Private Sub UserForm_Initialize()
'A textbox for the ID and TimeStamp was missing on the form
Me.TextBox1.Tag = "A" 'ID
Me.TextBox2.Tag = "B" 'TimeStamp
'You can hide it:
'Me.TextBox1.Visible = False
'Me.TextBox2.Visible = False
'Your controls:
Me.listGL.Tag = "C"
Me.listDate.Tag = "D"
Me.listEmployee.Tag = "G"
Me.listProjectName.Tag = "H"
Me.ProjectNumber.Tag = "I"
Me.listSection1.Tag = "J"
Me.listTask1.Tag = "K"
Me.listHours1.Tag = "L"
Me.listSection2.Tag = "N"
Me.listTask2.Tag = "O"
Me.listHours2.Tag = "P"
Me.listSection3.Tag = "R"
Me.listTask3.Tag = "S"
Me.listHours3.Tag = "T"
Me.listSection4.Tag = "V"
Me.listTask4.Tag = "W"
Me.listHours4.Tag = "X"
End Sub
Bookmarks