Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello All,
Is there a way to use VBA to add a certain number of checkboxes (or anything else) to a userform? For example, I may need anywhere from 3 to 7 checkboxes on a userform. I would prefer to build just one instead of 5 different userforms. Thanks for the help. Bill |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bill
For such a limited task, I believe I'd create 7 boxes and set the visibility to False for the ones I don't need at runtime. But sure, see John Walkenbach's code at http://www.j-walk.com/ss/excel/tips/tip76.htm HTH. Best wishes Harald "Bill" skrev i melding ink.net... Hello All, Is there a way to use VBA to add a certain number of checkboxes (or anything else) to a userform? For example, I may need anywhere from 3 to 7 checkboxes on a userform. I would prefer to build just one instead of 5 different userforms. Thanks for the help. Bill |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I find it much simpler to add all the controls I need to the userform.
But hide them until they're needed (.visible = false) Bill wrote: Hello All, Is there a way to use VBA to add a certain number of checkboxes (or anything else) to a userform? For example, I may need anywhere from 3 to 7 checkboxes on a userform. I would prefer to build just one instead of 5 different userforms. Thanks for the help. Bill -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub SpawnCheckBoxes()
Dim CheckBoxTotal As Long Dim cnt As Integer Dim myCB As Control CheckBoxTotal = Application.InputBox("How many CheckBoxes would you like?", "Creating CheckBoxes...", 3, , , , , 1) For cnt = 1 To CheckBoxTotal Set myCB = frmMyForm.Controls.Add("Forms.Checkbox.1", "myCB" & cnt) With myCB .Left = 0 .Top = (cnt * 15) - 15 .Object.Caption = "Hello From CheckBox" & cnt .Object.Value = True .Object.AutoSize = True End With Next frmMyForm.Show End Sub Try that post back if you have problems HTH Die_Another_Day Bill wrote: Hello All, Is there a way to use VBA to add a certain number of checkboxes (or anything else) to a userform? For example, I may need anywhere from 3 to 7 checkboxes on a userform. I would prefer to build just one instead of 5 different userforms. Thanks for the help. Bill |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to clear all checkboxes on a form? | Excel Worksheet Functions | |||
Adding multiple checkboxes | Excel Discussion (Misc queries) | |||
adding checkboxes | Excel Programming | |||
Adding Checkboxes Programmatically | Excel Programming | |||
Adding Checkboxes | Excel Programming |