ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting values from a dynamic userform (https://www.excelbanter.com/excel-programming/330781-getting-values-dynamic-userform.html)

SupC

Getting values from a dynamic userform
 

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.


--
SupC
------------------------------------------------------------------------
SupC's Profile: http://www.excelforum.com/member.php...o&userid=23941
View this thread: http://www.excelforum.com/showthread...hreadid=376054


Tom Ogilvy

Getting values from a dynamic userform
 
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

--
Regards,
Tom Ogilvy

"SupC" wrote in message
...

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.


--
SupC
------------------------------------------------------------------------
SupC's Profile:

http://www.excelforum.com/member.php...o&userid=23941
View this thread: http://www.excelforum.com/showthread...hreadid=376054




SupC[_2_]

Getting values from a dynamic userform
 

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


--
SupC
------------------------------------------------------------------------
SupC's Profile: http://www.excelforum.com/member.php...o&userid=23941
View this thread: http://www.excelforum.com/showthread...hreadid=376054



All times are GMT +1. The time now is 12:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com