Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controls on worksheet

Status
Not open for further replies.

FJAY

Programmer
Apr 23, 2003
106
0
0
CA
Good Morning - I have a worksheet in excel with about 20 checkboxes and I will like to set the value of each checkboxes on the click of a button without having to spell out the name of each checkboxes. Is this possible. I know in Visual Basic I can create an array of checkboxes. But I don't know how to do this in excel vba. I created each checkbox separetly. Thanks.

Dim myU, myP, strCB

'equipments for UA-AAL1
myU = Array(chkPP8600.Name, chkCMT.Name, chkMDM.Name,
chkPP15k.Name, chkSAM21.Name, chkGWC.Name,chkMG9kEM.Name)

myP = Array(chkPP8600.Name, chkCMT.Name, chkMDM.Name,
chkPP15k.Name, chkSAM21.Name, chkGWC.Name, _
chkIWSPM.Name, chkDPTSPM.Name,)

If optmyU.Value = True Then
For Each strCB In myU
Controls(strCB).Value = True
Next
elseif optmyP.value = true then
For Each strCB In myP
Controls(strCB).Value = True
Next
else
end if
 
Check box has a property that links it to a worksheet cell. If you link each of your check boxes to a cell in a range (e.g., AA1..AA20) then you can set them all off by setting the values in the range to FALSE or zero.

For example, if the range is named BOXCONTROLS then one line of code can set them all off:
[tt]
Range("BOXCONTROLS").Value = False
[/tt]

 
The controls are checkbox object. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top