Option Explicit
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
iRow = ws.Cells(Rows.Count, 2) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Please enter your Code"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
ws.Cells(iRow, 14).Value = Me.ComboBox1.Value
ws.Cells(iRow, 15).Value = Me.ComboBox2.Value
ws.Cells(iRow, 16).Value = Me.ComboBox3.Value
ws.Cells(iRow, 17).Value = Me.ComboBox4.Value
ws.Cells(iRow, 18).Value = Me.ComboBox5.Value
ws.Cells(iRow, 19).Value = Me.ComboBox6.Value
ws.Cells(iRow, 20).Value = Me.ComboBox7.Value
ws.Cells(iRow, 21).Value = Me.ComboBox8.Value
ws.Cells(iRow, 22).Value = Me.ComboBox9.Value
ws.Cells(iRow, 23).Value = Me.ComboBox10.Value
'clear the data
Me.TextBox1.Value = ""
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.ComboBox3.Value = ""
Me.ComboBox4.Value = ""
Me.ComboBox5.Value = ""
Me.ComboBox6.Value = ""
Me.ComboBox7.Value = ""
Me.ComboBox8.Value = ""
Me.ComboBox9.Value = ""
Me.ComboBox10.Value = ""
Me.TextBox1.SetFocus
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
ComboBox1.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox2.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox3.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox4.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox5.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox6.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox7.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox8.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox9.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
ComboBox10.List = Array("13:30:00", "18:00:00", "09:00:00", "22:30:00", "Holiday", "Annual Leave", "Self Opted")
End Sub
Bookmarks