userform with many buttons

D

diddi

i have a userform with 60 commandbuttons and need some code to loop
through them all, making the ones without captions set to
..visible=false
can't seem to get variables defined properly.

any assistance greatly apprecieted =)
 
R

Rod Gill

Try:

Private Sub UserForm_Click()
Dim O As Object
For Each O In UserForm1.Controls
If O.Caption = "" Then
O.Visible = False
End If
Next
End Sub
 

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

Top