Getting values from a dynamic userform

  • Thread starter Thread starter SupC
  • Start date Start date
S

SupC

The spreadsheet contains x number of possible data sets to chart. A
userform is dynamically created that contains x number of checkboxes.

How do I find out which check box(es) were selected? The problem is
that the number of data sets/checkboxes can vary depending upon which
spreadsheet is opened.

On a seperate note, why is it different code to show a dynamically
created userform than one created in the VBE?

VBA.UserForms.Add(VBComp.Name).Show

vs.

UserForm1.Show


Thank you.
 
assume fForm is a reference to your userform

dim cbx as MSForms.Checkbox
for each c in fForm.Components
if typeof c is msforms.checkbox then
set cbx = c
msgbox c.Name & "is checked: " & cbx.Value
end if
Next
 
Thanks Tom,

I tried the code but I get a compile error on the For Each line that
says:

Compile Error:

Method or data member not found

Regards,

Sup
 
Back
Top