Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Kenneth.
I've taken the simpler route of creating a procedure to trap changes to each OptionButton; however, I'm going to hold onto to your code and will include it as I refine my "solution." Thanks for your help; I appreciate it! Bert. "Kenneth Hobson" wrote in message ... As Leith said, doing it is a bit more effort than it may be worth. Here is one way using the Click event rather than a Change event in a Class. 1. Create your UserForm1 with the option buttons and TextBox1. 2. Add a class and use this code. Name the class in the project explorer as cOptionButtons. Private WithEvents obttn1 As MSForms.OptionButton Sub SendOptionButton(ByVal obttn As MSForms.OptionButton) Set obttn1 = obttn End Sub Private Sub obttn1_Click() If obttn1.Value = True Then IncrementTB1 obttn1 End Sub 3. Add a Module with this code. Sub IncrementTB1(ob As MSForms.OptionButton) If UserForm1.TextBox1.Value = "" Then UserForm1.TextBox1.Value = "0" UserForm1.TextBox1.Value = CStr(CDbl(UserForm1.TextBox1.Value) + CDbl(ob.Tag)) End Sub 4. Add this code to UserForm1. The use of the Tag property makes this a bit easier. Dim ob() As cOptionButtons Private Sub UserForm_Initialize() Dim obj As MSForms.Control, i As Long For Each obj In Me.Controls If TypeName(obj) = "OptionButton" Then i = i + 1 ReDim Preserve ob(i) Set ob(i) = New cOptionButtons ob(i).SendOptionButton obj obj.Tag = i End If Next End Sub Private Sub CommandButton1_Click() MsgBox TextBox1.Value Unload Me End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
apply cell change event to single column - WorksheetChange Event | Excel Programming | |||
How do I change a Worksheet_change event to a beforesave event? | Excel Programming | |||
MsgBox in Enter event causes combobox not to run Change event | Excel Programming | |||
Change event and calculate event | Excel Programming | |||
change event/after update event?? | Excel Programming |