Private Sub CommandButton1_Click()
On Error GoTo 1
Sheet = ComboBox1.Text
If Sheet = "" Then
MsgBox "Select Class", vbInformation, "Error"
Exit Sub
End If
'Update each class sheet Code
Sheets(Sheet).Select
Set findBlank = Range("A1:A32").Find(What:="", lookat:=xlWhole)
findBlank.Select
ActiveCell.Value = TextBox1.Text
ActiveCell.Offset(0, 1).Value = TextBox2.Text
ActiveCell.Offset(0, 2).Value = ComboBox2.Text
ActiveCell.Offset(0, 3).Value = TextBox3.Text
ActiveCell.Offset(0, 4).Value = TextBox4.Text
ActiveCell.Offset(0, 5).Value = TextBox5.Text
ActiveCell.Offset(0, 6).Value = ComboBox3.Text
ActiveCell.Offset(0, 7).Value = TextBox6.Text
ActiveCell.Offset(0, 8).Value = ComboBox4.Text
ActiveCell.Offset(0, 9).Value = TextBox7.Text
ActiveCell.Offset(0, 10).Value = TextBoX8.Text
ActiveCell.Offset(0, 11).Value = TextBox9.Text
ActiveCell.Offset(0, 12).Value = TextBox10.Text
ActiveCell.Offset(0, 13).Value = TextBox11.Text
If OptionButton1 = True Then
ActiveCell.Offset(0, 14).Value = "Y"
ElseIf OptionButton2 = True Then
ActiveCell.Offset(0, 14).Value = "N"
End If
ActiveCell.Offset(0, 15).Value = TextBox12.Text
'Update Master Sheet
If Sheet = "MASTER SHEET" Then
MsgBox "Select Class", vbInformation, "Error"
Exit Sub
End If
Sheets("MASTER SHEET").Select
Set findBlank = Range("A1:A90").Find(What:="", lookat:=xlWhole)
findBlank.Select
ActiveCell.Value = TextBox1.Text
ActiveCell.Offset(0, 1).Value = TextBox2.Text
ActiveCell.Offset(0, 2).Value = ComboBox2.Text
ActiveCell.Offset(0, 3).Value = TextBox3.Text
ActiveCell.Offset(0, 4).Value = TextBox4.Text
ActiveCell.Offset(0, 5).Value = TextBox5.Text
ActiveCell.Offset(0, 6).Value = ComboBox3.Text
ActiveCell.Offset(0, 7).Value = TextBox6.Text
ActiveCell.Offset(0, 8).Value = ComboBox4.Text
ActiveCell.Offset(0, 9).Value = TextBox7.Text
ActiveCell.Offset(0, 10).Value = TextBoX8.Text
ActiveCell.Offset(0, 11).Value = TextBox9.Text
ActiveCell.Offset(0, 12).Value = TextBox10.Text
ActiveCell.Offset(0, 13).Value = TextBox11.Text
If OptionButton1 = True Then
ActiveCell.Offset(0, 14).Value = "Y"
ElseIf OptionButton2 = True Then
ActiveCell.Offset(0, 14).Value = "N"
End If
ActiveCell.Offset(0, 15).Value = TextBox12.Text
ActiveCell.Offset(0, 16).Value = Sheet
ActiveCell.Offset(0, 17).Value = ComboBox5.Text
If OptionButton3 = True Then
ActiveCell.Offset(0, 18).Value = "Y"
Else
ActiveCell.Offset(0, 18).Value = "N"
End If
'Sort Master Sheet
ActiveWorkbook.Worksheets("MASTER SHEET").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("MASTER SHEET").Sort.SortFields.Add Key:=Range("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("MASTER SHEET").Sort
.SetRange Range("A2:S90")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Update Address Master Sheet
If Sheet = "ADDRESS MASTER SHEET" Then
MsgBox "Select Class", vbInformation, "Error"
Exit Sub
End If
Sheets("ADDRESS MASTER SHEET").Select
Set findBlank = Range("A1:A72").Find(What:="", lookat:=xlWhole)
findBlank.Select
ActiveCell.Value = TextBox1.Text
ActiveCell.Offset(0, 1).Value = TextBox2.Text
ActiveCell.Offset(0, 2).Value = TextBox5.Text
ActiveCell.Offset(0, 3).Value = ComboBox3.Text
ActiveCell.Offset(0, 4).Value = TextBoX8.Text
ActiveCell.Offset(0, 5).Value = ComboBox5.Text
ActiveCell.Offset(0, 6).Value = Sheet
'Sort Address Master Sheet
ActiveWorkbook.Worksheets("ADDRESS MASTER SHEET").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ADDRESS MASTER SHEET").Sort.SortFields.Add Key:=Range( _
"C2:C100"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ADDRESS MASTER SHEET").Sort
.SetRange Range("A1:G72")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Clear Form
ComboBox1.Text = ""
TextBox1.Value = ""
TextBox2.Value = ""
ComboBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
ComboBox3.Value = ""
ComboBox4.Value = ""
TextBox7.Value = ""
TextBoX8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
OptionButton1.Value = ""
OptionButton2.Value = ""
OptionButton3.Value = ""
OptionButton4.Value = ""
TextBox12.Value = ""
ComboBox5.Value = ""
Exit Sub
1: MsgBox "Error: Sheet Full"
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "PREK-K"
.AddItem "1ST-2ND"
.AddItem "3RD-4TH"
.AddItem "5TH-6TH BOYS"
.AddItem "5TH-6TH GIRLS"
With ComboBox2
.AddItem "PREK"
.AddItem "K"
.AddItem "1ST"
.AddItem "2ND"
.AddItem "3RD"
.AddItem "4TH"
.AddItem "5TH"
.AddItem "6TH"
With ComboBox3
.AddItem "Piedmont"
.AddItem "Patterson"
With ComboBox4
.AddItem "63957"
.AddItem "63956"
With ComboBox5
.AddItem "1"
.AddItem "2"
.AddItem "3"
End With
End With
End With
End With
End With
End Sub