TerenceTitus
New Member
- Joined
- Feb 8, 2017
- Messages
- 20
Hi,
I am facing some trouble formulating a macro to run upon closure of workbook. I would like to run a macro to check if there are unselected option buttons within my specific sheet. The option buttons grouped in rows of 5 where only 1 can be selected per row and it runs down as long as the survey continues.
It does not prompt me on unselected option buttons and I cant make the macro end if the user selects do not close survey.
I am facing some trouble formulating a macro to run upon closure of workbook. I would like to run a macro to check if there are unselected option buttons within my specific sheet. The option buttons grouped in rows of 5 where only 1 can be selected per row and it runs down as long as the survey continues.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each vctrl In ActiveWorkbook.Worksheets("Survey").Shapes
If vctrl.Type = msoFormControl Then
If vctrl.FormControlType = xlOptionButton Then
If vctrl.DrawingObject.Value = False Then MsgBox Prompt:="You have not answered all questions!"
If MsgBox("Do you still want to close the survey?", vbYesNo) = vbNo Then Exit Sub
End If
End If
Next
End Sub
It does not prompt me on unselected option buttons and I cant make the macro end if the user selects do not close survey.
Last edited: