View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
robotman robotman is offline
external usenet poster
 
Posts: 51
Default Referencing form controls with a loop

I have a form that has 12 identical lines (same label, button, field
etc.).

In normal VB, I can create each control as an array, ex.
frmMyForm.lblMyLabel(1).
So this works great for changing something for all the controls with a
loop:

For Myloop = 1 to 12
frmMyForm.btnMyButton(MyLoop).Enabled = False
Next MyLoop

In VBA, I have to independently name each control and reference them
each one by one:

frmMyForm.btnMybutton1.Enabled = False
frmMyForm.btnMybutton2.Enabled = False
...
frmMyForm.btnMybutton12.Enabled = False

Does anyone have a shortcut to reference multiple identical controls
with a loop in VBA?!

Thanks.

John