Derek Schauland
asked on
Using data from a dynamic vba form in Excel
I have created a dynamic form in Excel vba to loop through a column and add checkboxes with the column items as captions on the form.
My goal is to use the form as a voting form where a user would check the boxes for the choices needed and click the submit button, then for each box checked, the column in Excel would be updated +1 to count total votes for a selection.
I cannot get the submit and count of votes for checked boxes to work at all. Any assistance provided would be greatly appreciated
Derek
My goal is to use the form as a voting form where a user would check the boxes for the choices needed and click the submit button, then for each box checked, the column in Excel would be updated +1 to count total votes for a selection.
I cannot get the submit and count of votes for checked boxes to work at all. Any assistance provided would be greatly appreciated
Derek
Can you attach your workbook or show the code you are using to add the controls and the code you use to add up the checks?
ASKER
Absolutely
the workbook is attached. On the first page, there is a button to launch the form, on the second the list of captions and results fields are in columns a and b.
votesxlsx.xlsm
the workbook is attached. On the first page, there is a button to launch the form, on the second the list of captions and results fields are in columns a and b.
votesxlsx.xlsm
You should always have Option Explicit at the top of your userform's code.
What/where is mycontrol3?
What/where is mycontrol3?
Never mind I understand mycontrol 13.
ASKER
That whole section can be tweaked as needed... was trying to find out how to access dynamically generated controls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to accumulate the votes, change line 12 to Cells(r, 2).Value = Cells(r, 2).Value + 1
ASKER
This is awesome. Thanks so much for your help
For line 9 you can also do something like
If TypeOf ctl Is msforms.CheckBox Then
In any case you're welcome and I'm glad I was able to help.
Marty - MVP 2009 to 2012
If TypeOf ctl Is msforms.CheckBox Then
In any case you're welcome and I'm glad I was able to help.
Marty - MVP 2009 to 2012