View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Charles Chickering Charles Chickering is offline
external usenet poster
 
Posts: 272
Default generate a form at runtime?

JJ, I've used this approach to make dynamic checkboxes
Dim ctlCheckBox As Control
For cnt = 1 to 10
Set ctlCheckBox = UserForm1.Controls.Add _
("Forms.Checkbox.1", "ctlCheckBox" & cnt)
ctlCheckBox.Caption = ActiveWorkbook.Worksheets(cnt).Name
Next

then call back the info like this:
For cnt = 1 to 10
MsgBox UserForm1.Controls("ctlCheckBox" & cnt).Value
Next
--
Charles Chickering

"A good example is twice the value of good advice."


"Andy Pope" wrote:

Rather than adding controls consider a listbox with the properties

ListStyle = fmListStyleOption
MultiSelect = fmMultiSelectMulti

Cheers
Andy

JJ wrote:
Ok. Heres what i want to do.

I have a variable number of sheets with variable names.

I want to at runtime produce a form which lists all the sheets and a
check box for each one.

this is for my users to select which of there sheets they want to run
the macro on.

Can any one point me in the right direction ?

Or is there a better way to do this?

Thanks in advance!

J


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info