Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Adding Checkboxes to a Form

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Adding Checkboxes to a Form

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Adding Checkboxes to a Form

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Adding Checkboxes to a Form

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to clear all checkboxes on a form? Arlen Excel Worksheet Functions 2 May 6th 10 04:20 PM
Adding multiple checkboxes timmeah4 Excel Discussion (Misc queries) 7 December 6th 06 02:48 PM
adding checkboxes shadespool Excel Programming 2 May 17th 06 06:46 PM
Adding Checkboxes Programmatically Mark D'Agosta Excel Programming 1 October 8th 03 03:20 AM
Adding Checkboxes Wes[_3_] Excel Programming 2 July 31st 03 11:27 PM


All times are GMT +1. The time now is 09:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"