Hello all,
I come as a novice seeking advice from the amazing minds I see here!
Guided by this code:
Posted by Andrew Poulsom here:
http://www.mrexcel.com/forum/excel-questions/65901-multiple-textboxes-same-code.html
- I have successfully applied my first Class module to a group of ComboBoxes.
Now I would like to somehow include a group of 4 OptionButtons (all in one frame) in that same Class module: When any of the OptionButtons is selected, that should set off the exact same procedure as the change event of the ComboBoxes.
I don't know how to achieve this and am hoping for some guidance.
I have tried to follow the same piece of code and apply it to OptionButtons: I created a new Class module, but I get lost when it comes to the code that would go in the UserForm module.
Besides, it seems repetitive - which was the very thing I set out to remedy - and I suspect there is a simpler and more elegant way to go about it: somehow including OptionButtons in the code already provided.
In anticipation, and with advance gratitude,
Cheers,
Melpa
I come as a novice seeking advice from the amazing minds I see here!
Guided by this code:
Code:
' Class module named TBClass
Public WithEvents TBGroup As MSForms.TextBox
Private Sub TBGroup_Change()
MsgBox TBGroup.Name & " changed"
End Sub
' UserForm module
Dim TBs() As New TBClass
Private Sub UserForm_Initialize()
Dim TBCount As Integer
Dim Ctrl As Control
TBCount = 0
For Each Ctrl In UserForm1.Controls
If TypeName(Ctrl) = "TextBox" Then
TBCount = TBCount + 1
ReDim Preserve TBs(1 To TBCount)
Set TBs(TBCount).TBGroup = Ctrl
End If
Next Ctrl
End Sub
http://www.mrexcel.com/forum/excel-questions/65901-multiple-textboxes-same-code.html
- I have successfully applied my first Class module to a group of ComboBoxes.
Now I would like to somehow include a group of 4 OptionButtons (all in one frame) in that same Class module: When any of the OptionButtons is selected, that should set off the exact same procedure as the change event of the ComboBoxes.
I don't know how to achieve this and am hoping for some guidance.
I have tried to follow the same piece of code and apply it to OptionButtons: I created a new Class module, but I get lost when it comes to the code that would go in the UserForm module.
Besides, it seems repetitive - which was the very thing I set out to remedy - and I suspect there is a simpler and more elegant way to go about it: somehow including OptionButtons in the code already provided.
In anticipation, and with advance gratitude,
Cheers,
Melpa