Hello,
I'm trying to write only my second UserForm and have bitten off more than I can chew! Here's hoping that some kind soul will be able to help me out.
I'm using Excel 2010. My user form contains a series of frames which contain text boxes, labels, list boxes, option buttons and/or command buttons (I'll call these frames and the objects they contain "frame sets"). Depending on the responses to one of the objects in a frame, another frame set will appear or disappear as the user is led through a series of questions.
I'm having two problems:
The ActiveX command buttons, when clicked, do not elicit a response (that is, the next frame does not appear or disappear as it should). Here's an example of the code (contained in the UserForm1 module) for one of the command buttons:
My second problem is with the list boxes . . .
The list boxes contain lists of 3-5 items, the last one being 'None of the above.' I would like to write code that, when that item is selected, de-selects any other items above it that may have been checked. Again, I cannot figure out how to write code that will do that. (I do know that List Items are numbered starting with zero.) Here's what I've written . . .
I am happy to attach the actual file but cannot figure out how to do so. I would willingly e-mail it to anybody who's willing to help me.
I've gotten a lot of help from members of this forum in the past. Please know that your willingness to help out random, anonymous strangers is much appreciated.
Michele
I'm trying to write only my second UserForm and have bitten off more than I can chew! Here's hoping that some kind soul will be able to help me out.
I'm using Excel 2010. My user form contains a series of frames which contain text boxes, labels, list boxes, option buttons and/or command buttons (I'll call these frames and the objects they contain "frame sets"). Depending on the responses to one of the objects in a frame, another frame set will appear or disappear as the user is led through a series of questions.
I'm having two problems:
The ActiveX command buttons, when clicked, do not elicit a response (that is, the next frame does not appear or disappear as it should). Here's an example of the code (contained in the UserForm1 module) for one of the command buttons:
Code:
Public Sub cmdContinueFromMechanicalValve_Click()
If lstValveMechanical.ListCount < 0 Then
HideSchedProcedure 'this hides the frame set named 'SchedProcedure'
HideVTE 'this hides the frame set named 'VTE'
MsgBox "You have not selected a mechanical valve type(s).", vbCritical, "Mechanical valve type not selected"
ElseIf lstValveMechanical.ListCount = 0 _
Or lstValveMechanical.ListCount = 1 Then
HideValveBioprosthetic 'this hides the frame set named 'ValveBioprosthetic'
ShowSchedProcedure 'this unhides the frame set named 'SchedProcedure'
ElseIf lstValveMechanical.ListCount = 2 Then
HideSchedProcedure 'this hides the frame set named 'SchedProcedure'
ShowValveBioprosthetic 'this unhides the frame set named 'ValveBioprosthetic'
End If
End Sub
My second problem is with the list boxes . . .
The list boxes contain lists of 3-5 items, the last one being 'None of the above.' I would like to write code that, when that item is selected, de-selects any other items above it that may have been checked. Again, I cannot figure out how to write code that will do that. (I do know that List Items are numbered starting with zero.) Here's what I've written . . .
Code:
Private Sub lstVTE_Click()
' Clears previously selected options when 'none of the above' is clicked
If lstVTE.ListIndex = 5 Then 'ListIndex item 5 is 'None of the above'
lstVTE.Clear
lstVTE.ListIndex = 5 'Re-selects item 5
End If
End Sub
I am happy to attach the actual file but cannot figure out how to do so. I would willingly e-mail it to anybody who's willing to help me.
I've gotten a lot of help from members of this forum in the past. Please know that your willingness to help out random, anonymous strangers is much appreciated.
Michele