For UF Production
Code:
Private Sub CommandButton1_Click()
'check user input
For Each ctl In Me.Controls
If ctl.Tag <> vbNullString Then
If ctl.Value = vbNullString Then MsgBox ctl.Tag: ctl.SetFocus: Exit Sub
End If
Next
'write data to worksheet
With Sheets(ComboBox2.Value)
.Unprotect Password:="abc"
.Cells(.Cells(.Rows.Count, "B").End(xlUp).Row + 1, 2).Resize(, 5) = Array(ComboBox1.Value, _
ComboBox3.Value, TextBox1.Text, TextBox3.Text, TextBox4.Text)
.Cells(.Cells(.Rows.Count, "B").End(xlUp).Row, 2).Offset(, 5).Resize(, 11).Interior.ColorIndex = 3
.Protect Password:="abc"
End With
'Clear all fields
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = vbNullString
Next
End Sub
For UF Planned_Stop
Code:
Private Sub CommandButton1_Click()
'check user input
For Each ctl In Me.Controls
If ctl.Tag <> vbNullString Then
If ctl.Value = vbNullString Then MsgBox ctl.Tag: ctl.SetFocus: Exit Sub
End If
Next
'write data to worksheet
With Sheets(ComboBox2.Value)
.Unprotect Password:="abc"
.Cells(.Cells(.Rows.Count, "B").End(xlUp).Row + 1, 2).Resize(, 8) = Array(ComboBox1.Value, , , , , _
ComboBox3.Value, TextBox1.Text, TextBox2.Text)
.Protect Password:="abc"
End With
'Clear all fields
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = vbNullString
Next
End Sub
For UF MachineStoppage
Code:
Private Sub CommandButton1_Click()
'check user input
For Each ctl In Me.Controls
If ctl.Tag <> vbNullString Then
If ctl.Value = vbNullString Then MsgBox ctl.Tag: ctl.SetFocus: Exit Sub
End If
Next
'write data to worksheet
With Sheets(ComboBox2.Value)
.Unprotect Password:="abc"
.Cells(.Cells(.Rows.Count, "B").End(xlUp).Row + 1, 2).Resize(, 16) = Array(ComboBox1.Value, , , , , , , , _
ComboBox4.Value, ComboBox5.Value, ComboBox6.Value, IIf(ComboBox3.ListIndex = 0, TextBox2.Text, ""), _
ComboBox7.Value, ComboBox8.Value, IIf(ComboBox3.ListIndex = 1, TextBox2.Text, ""), TextBox1.Text)
.Protect Password:="abc"
End With
'Clear all fields
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = vbNullString
Next
End Sub
Bookmarks