Create dynamic userform with unique value as checkboxes

YasserKhalil
PlatinumLounger
Posts: 4930
Joined: 31 Aug 2016, 09:02

Create dynamic userform with unique value as checkboxes

Post by YasserKhalil »

Hello everyone
I have a worksheet with values in column D from D2 to the last row. I need to create userform on the fly with checkboxes for the user with each unique value and beside each checkbox a label for each checkbox and at the bottom command button that has a macro to execute say MsgBox "Hello",64

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Create dynamic userform with unique value as checkboxes

Post by HansV »

What is the maximum number of rows you expect?
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4930
Joined: 31 Aug 2016, 09:02

Re: Create dynamic userform with unique value as checkboxes

Post by YasserKhalil »

About 10,000 rows. But the unique values will be maximum 12 values (or even 6 values)

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: Create dynamic userform with unique value as checkboxes

Post by rory »

You could simply use a listbox with its ListStyle set to fmListStyleOption.
Regards,
Rory

YasserKhalil
PlatinumLounger
Posts: 4930
Joined: 31 Aug 2016, 09:02

Re: Create dynamic userform with unique value as checkboxes

Post by YasserKhalil »

But I need checkboxes as the user may select more than one option.

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: Create dynamic userform with unique value as checkboxes

Post by rory »

Try it. Forgot to mention that you will of course want to make the listbox multiselect!
Regards,
Rory

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Create dynamic userform with unique value as checkboxes

Post by HansV »

The userform listbox control has a MultiSelect property. You can set it to 1 - fmMultiSelectMulti or to 2 - fmMultiSelectExtended.
Best wishes,
Hans