Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
checkboxes and option buttons
XP pro, xl2002
hi i have a userform with several checkboxes. if any of them are checked i want their captions to be concatenated together with some text in a textbox to be transferred together into another textbox at the click of a button. eg, textbox1 = "TVC" checkbox1 = checked (caption "-1") checkbox2 = unchecked (caption "-2") checkbox3 = checked (caption "-3") so, textbox2 would = "TVC-1-3" i CAN do all of this, but want to know if there is an efficient way of working through each checkbox (of which there are 7) subsequently, a smilar solution for the optionbuttons (although, obviously only one will be 'true') in addition (if it makes a difference), all the checkboxes are in one frame and the option buttons in another frame - these are bth enclosed in another frame... currently for aesthetic purposes, but don't know if it makes any difference to what i want to achieve. can i refer to all objects enclosed in a frame? thanks all, tim |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
checkboxes and option buttons
If your checkboxes are nicely named: checkbox1 through checkbox7, then maybe
something like: Option Explicit Private Sub CommandButton1_Click() Dim iCtr As Long Dim myStr As String myStr = Me.TextBox1.Value For iCtr = 1 To 7 With Me.Controls("checkbox" & iCtr) If .Value = True Then myStr = myStr & .Caption End If End With Next iCtr Me.TextBox2.Value = myStr End Sub Tim wrote: XP pro, xl2002 hi i have a userform with several checkboxes. if any of them are checked i want their captions to be concatenated together with some text in a textbox to be transferred together into another textbox at the click of a button. eg, textbox1 = "TVC" checkbox1 = checked (caption "-1") checkbox2 = unchecked (caption "-2") checkbox3 = checked (caption "-3") so, textbox2 would = "TVC-1-3" i CAN do all of this, but want to know if there is an efficient way of working through each checkbox (of which there are 7) subsequently, a smilar solution for the optionbuttons (although, obviously only one will be 'true') in addition (if it makes a difference), all the checkboxes are in one frame and the option buttons in another frame - these are bth enclosed in another frame... currently for aesthetic purposes, but don't know if it makes any difference to what i want to achieve. can i refer to all objects enclosed in a frame? thanks all, tim -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Buttons shrinking and checkboxes swelling... | Excel Discussion (Misc queries) | |||
My CheckBoxes and Option Buttons Grow/Shrink each time I click the | Excel Discussion (Misc queries) | |||
creating checkboxes and radio buttons in excel | Excel Worksheet Functions | |||
Checkboxes vs. Option Buttons | Excel Discussion (Misc queries) | |||
Excel: unlocking buttons & checkboxes | Excel Programming |