How do I get a reference to a control on a sheet?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using VBA in Excel XP and Win 2k

I have several drop down controls on a sheet. The control are NOT ActiveX objects.

How do I loop through all the controls on the sheet and set them all to list index 0 (the first choice)

Thanks.
 
I am using VBA in Excel XP and Win 2k.
I have several drop down controls on a sheet. The control are NOT ActiveX objects.

How do I loop through all the controls on the sheet and set them all to list index 0 (the first choice)?

try this:

Sub ResetDropDown()
Dim shpDropDown As Shape

For Each shpDropDown In ActiveSheet.Shapes
If shpDropDown.FormControlType = xlDropDown Then
shpDropDown.ControlFormat.ListIndex = 1
End If
Next shpDropDown
End Sub


--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top