Private Sub UserForm_Initialize()
Question1.Caption = Worksheets("Day 1 Answers").Range("C1").Value
Question2.Caption = Worksheets("Day 1 Answers").Range("E1").Value
Question3.Caption = Worksheets("Day 1 Answers").Range("G1").Value
Question4.Caption = Worksheets("Day 1 Answers").Range("I1").Value
Question5.Caption = Worksheets("Day 1 Answers").Range("K1").Value
Question6.Caption = Worksheets("Day 1 Answers").Range("M1").Value
Question7.Caption = Worksheets("Day 1 Answers").Range("O1").Value
Question8.Caption = Worksheets("Day 1 Answers").Range("Q1").Value
Combobox1.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_1").RefersToRange)
Combobox2.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_2").RefersToRange)
combobox3.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_3").RefersToRange)
ComboBox4.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_4").RefersToRange)
ComboBox5.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_5").RefersToRange)
ComboBox6.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_6").RefersToRange)
ComboBox7.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_7").RefersToRange)
ComboBox8.List = WorksheetFunction.Transpose(ThisWorkbook.Names("Survey_1_Question_8").RefersToRange)
End Sub
Private Sub Survey_Initialize()
'Empty FirstNametxt
FirstNametxt.Value = ""
'Empty LastNametxt
LastNametxt.Value = ""
'Set Focus on FirstNametxt
FirstNametxt.SetFocus
End Sub
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub ClearButton_Click()
Call Survey_Initialize
End Sub
Private Sub MultiPage1_Change()
Me.MultiPage1.Value = 0
End Sub
Private Sub ClearButton1_Click()
Dim ctl As MSForms.Control
For Each ctl In Me.Controls
Select Case TypeName(ctl)
Case "TextBox"
ctl.Text = ""
Case "CheckBox", "OptionButton", "ToggleButton"
ctl.Value = False
Case "ComboBox", "ListBox"
ctl.ListIndex = -1
End Select
Next ctl
End Sub
Private Sub OKButton_Click()
'error check - blank UserForm fields not permitted
If FirstNametxt.Text = "" Then
MsgBox "Please Enter First Name", vbOKOnly, "Name Error!"
Exit Sub
ElseIf LastNametxt.Text = "" Then
MsgBox "Please Enter Last Name", vbOKOnly, "Name Error!"
Exit Sub
ElseIf Combobox1.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf Combobox2.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf combobox3.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf ComboBox4.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf ComboBox5.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf ComboBox6.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf ComboBox7.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf ComboBox8.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf Textbox1.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf Textbox2.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf textbox3.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf TextBox4.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf TextBox5.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf TextBox6.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf TextBox7.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
ElseIf TextBox8.Value = "" Then
MsgBox "Please Complete Form", vbOKOnly, "Country Error!"
Exit Sub
End If
Dim emptyRow As Long
'Make Sheet2 active
Sheet2.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = FirstNametxt.Value
Cells(emptyRow, 2).Value = LastNametxt.Value
Cells(emptyRow, 3).Value = Combobox1.Value
Cells(emptyRow, 4).Value = Textbox1.Value
Cells(emptyRow, 5).Value = Combobox2.Value
Cells(emptyRow, 6).Value = Textbox2.Value
Cells(emptyRow, 7).Value = combobox3.Value
Cells(emptyRow, 8).Value = textbox3.Value
Cells(emptyRow, 9).Value = ComboBox4.Value
Cells(emptyRow, 10).Value = TextBox4.Value
Cells(emptyRow, 11).Value = ComboBox5.Value
Cells(emptyRow, 12).Value = TextBox5.Value
Cells(emptyRow, 13).Value = ComboBox6.Value
Cells(emptyRow, 14).Value = TextBox6.Value
Cells(emptyRow, 15).Value = ComboBox7.Value
Cells(emptyRow, 16).Value = TextBox7.Value
Cells(emptyRow, 17).Value = ComboBox8.Value
Cells(emptyRow, 18).Value = TextBox8.Value
'make sheet1 active
Sheet1.Activate
Unload Me
End Sub
Bookmarks