Hi all.
I am trying to develop a questionnaire with 50 questions. I can only fit 13 questions on the screen. Do I use scroll or split the form?
Each question has 5-options (very inaccurate, moderately inaccurate, neutral, moderately accurate, and very accurate). Each question has 5 option buttons grouped. So in all there will be 250 option buttons. The code is below with only the first question. The participant enters their number and the results are saved in a worksheet when the submit command button is clicked (copied this code from elsewhere and it works well).
I am very new to VBA and this is my first attempt. I have tried using scroll and setting ScrollBars property of the userform to 2 (frmScrollBarsVertical), and setting the ScrollHeight property to a value greater than the userform's height...which is at 950. This doesn't work (the scroll bar appears but is not functioning). Additionally, anything over height 1000, the form top is lost and excel freezes. Not sure how to fit in more than the 13 questions that fit on the screen.
I am developing it at home on Excel for Mac 2011, VBA version 14.2.5 (and will be running it on PCs in the lab).
Any pointers would be greatly appreciated.
I am trying to develop a questionnaire with 50 questions. I can only fit 13 questions on the screen. Do I use scroll or split the form?
Each question has 5-options (very inaccurate, moderately inaccurate, neutral, moderately accurate, and very accurate). Each question has 5 option buttons grouped. So in all there will be 250 option buttons. The code is below with only the first question. The participant enters their number and the results are saved in a worksheet when the submit command button is clicked (copied this code from elsewhere and it works well).
I am very new to VBA and this is my first attempt. I have tried using scroll and setting ScrollBars property of the userform to 2 (frmScrollBarsVertical), and setting the ScrollHeight property to a value greater than the userform's height...which is at 950. This doesn't work (the scroll bar appears but is not functioning). Additionally, anything over height 1000, the form top is lost and excel freezes. Not sure how to fit in more than the 13 questions that fit on the screen.
I am developing it at home on Excel for Mac 2011, VBA version 14.2.5 (and will be running it on PCs in the lab).
Any pointers would be greatly appreciated.
Code:
Option Explicit
Private Sub TextBoxSubjectNumber_Click()
End Sub
Private Sub TextBoxSubjectNumber_AfterUpdate()
Sheets("Results").Range("A2").Value = TextBoxSubjectNumber.Text
End Sub
Private Sub OptionButton1_Click()
Sheets("Results").Range("B2").Value = "1"
End Sub
Private Sub OptionButton2_Click()
Sheets("Results").Range("B2").Value = "2"
End Sub
Private Sub OptionButton3_Click()
Sheets("Results").Range("B2").Value = "3"
End Sub
Private Sub OptionButton4_Click()
Sheets("Results").Range("B2").Value = "4"
End Sub
Private Sub OptionButton5_Click()
Sheets("Results").Range("B2").Value = "5"
End Sub
Private Sub CommandButtonSubmitExit_Click()
Dim wb As Workbook
Dim FolderName As String
FolderName = TextBoxSubjectNumber.Text & _
Format(Now, "_dd-mm-yyyy hh-mm\")
Application.ScreenUpdating = False
On Error Resume Next
On Error GoTo 0
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs FolderName & ".xls", FileFormat:=xlWorkbookNormal
End With
Application.ScreenUpdating = True
Unload UserFormPreScenario
ActiveWindow.Close
End Sub