ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform and checkbox.... (https://www.excelbanter.com/excel-programming/285848-userform-checkbox.html)

ben.c

Userform and checkbox....
 
Hi,
I am doind a Userform with 20 checkbox on it. So to do their properties I would like to use a for next. I have try to do it with a string like str = checkbox & "k" but it doesn't work. And I don't know how to do it with an object. Do you know a way to do it ?
Thanks for help
Benjamin

Stephen Bullen

Userform and checkbox....
 
Hi Benjamin,

I am doind a Userform with 20 checkbox on it. So to do their properties I would like to use a for next. I have try to do it with a string like str = checkbox & "k" but it doesn't work. And I don't know how to do it with an object. Do you know a way to do it ?


You need to create their names as a string, then use the Controls() property to get the object:

Me.Controls("CheckBox " & k)

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk



ben.c

Userform and checkbox....
 
Euh....
I am sorry but I am not sure of how do I create their name as a string
Do I have to use checkbox.name to rename them
Thanks for help Stephe
Benjamin

Tom Ogilvy

Userform and checkbox....
 
for i = 1 to 10
controls("CheckBox" & i).Value = False
Next

as an example.

another approach

for each ctrl in Userform1.Controls
if typeof ctrl is MSForms.CheckBox then
ctrl.Value = false
end if
Next

--
Regards,
Tom Ogilvy

"Ben.c" wrote in message
...
Euh.....
I am sorry but I am not sure of how do I create their name as a string ?
Do I have to use checkbox.name to rename them ?
Thanks for help Stephen
Benjamin





All times are GMT +1. The time now is 08:04 AM.

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