Here's the whole thing...
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdClearForm_Click()
Call UserForm_Initialize
End Sub
Private Sub cmdOK_Click()
ActiveWorkbook.Sheets("Camera Report Form").Activate
Range("A7").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
If ActiveCell.Value = txtName.Value Then
ActiveCell.ClearContents
ActiveCell.Offset(0, 1).ClearContents
ActiveCell.Offset(0, 2).ClearContents
ActiveCell.Offset(0, 3).ClearContents
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtName.Value
ActiveCell.Offset(0, 3) = txtPhone.Value
ActiveCell.Offset(0, 2) = cboDepartment.Value
If chkLunch = True Then
cboCourse.Value = "BROKEN"
ActiveCell.Offset(0, 1) = cboCourse.Value
Else
ActiveCell.Offset(0, 1) = cboCourse.Value
End If
Columns("A:C").Select
With Selection
.HorizontalAlignment = xlCenter
End With
Range("A7").Select
Range("A7:E500").Sort Key1:=Range("A500"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns("A:D").Select
With Selection.font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With
Range("A7").Select
ActiveWorkbook.Sheets("Other").Activate
Range("A7").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtName.Value
ActiveCell.Offset(0, 3) = txtPhone.Value
ActiveCell.Offset(0, 2) = cboDepartment.Value
If chkLunch = True Then
cboCourse.Value = "BROKEN"
ActiveCell.Offset(0, 1) = cboCourse.Value
Else
ActiveCell.Offset(0, 1) = cboCourse.Value
End If
If cboCourse.Value = "1" Then
ActiveCell.Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 3
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 3
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 3
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 3
Selection.font.Bold = True
End If
If cboCourse.Value = "2" Then
ActiveCell.Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 9
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 9
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 9
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 9
Selection.font.Bold = True
End If
If cboCourse.Value = "3" Then
ActiveCell.Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 6
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 6
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 6
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 6
Selection.font.Bold = True
End If
If cboCourse.Value = "4" Then
ActiveCell.Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 10
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 10
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 10
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 10
Selection.font.Bold = True
End If
If cboCourse.Value = "5" Then
ActiveCell.Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 4
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 4
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 4
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 1
Selection.Interior.ColorIndex = 4
Selection.font.Bold = True
End If
If cboCourse.Value = "BROKEN" Then
ActiveCell.Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 2
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
End If
Range("A7").Select
Range("A6:D500").Sort Key1:=Range("A6"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A6:D500").Sort Key1:=Range("B6"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns("A:B").Select
With Selection
.HorizontalAlignment = xlCenter
End With
Columns("A:D").Select
With Selection.font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With
Range("A7").Select
ActiveWorkbook.Sheets("Broken").Activate
Range("A7").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
If chkLunch = True Then
ActiveCell.Offset(0, 1).Value = "BROKEN"
ActiveCell.Value = txtName.Value
ActiveCell.Offset(0, 3) = txtPhone.Value
ActiveCell.Offset(0, 2) = cboDepartment.Value
If chkpriority = True Then
ActiveCell.Select
Selection.font.ColorIndex = 6
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 6
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 6
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
ActiveCell.Offset(0, 1).Select
Selection.font.ColorIndex = 6
Selection.Interior.ColorIndex = 1
Selection.font.Bold = True
End If
End If
Range("A7").Select
Columns("A:C").Select
With Selection
.HorizontalAlignment = xlCenter
End With
Range("A7").Select
Range("A6:E500").Sort Key1:=Range("A500"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns("A:D").Select
With Selection.font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With
Range("A7").Select
ActiveWorkbook.Sheets("Camera Report Form").Activate
Range("A7").Select
End Sub
Private Sub UserForm_Initialize()
txtName.Value = ""
txtPhone.Value = ""
With cboDepartment
.AddItem "OK"
.AddItem "Blurry"
.AddItem "Wavy"
.AddItem "Fuzzy"
.AddItem "Limited Mobility"
.AddItem "Flickering"
.AddItem "Other"
.AddItem "Totally Black"
End With
cboDepartment.Value = ""
With cboCourse
.AddItem "1"
.AddItem "2"
.AddItem "3"
.AddItem "4"
.AddItem "5"
End With
cboCourse.Value = ""
txtName.SetFocus
End Sub
Private Sub chkLunch_Click()
If chkLunch.Value = True Then
cboCourse.Enabled = False
Else
cboCourse.Enabled = True
End If
End Sub