Looping thru custom controls

  • Thread starter Thread starter papou
  • Start date Start date
P

papou

Hi all
Excel 2K
I need to loop through a number of custom controls and enable some of them.
I can identify these controls with their .tag property which will always
begin with "AVV"
So I thought I could use the .FindControl method and the Like operator, but
I cannot figure out how to do it.
Could somebody explain how to achieve this?
TIA
Regards
Pascal
 
dim ctrl as Control
For Each Ctrl in Controls

If ctrl.Tag LIKE "TVV*" Then
ctrl.Enabled = True
End If

Next



HTH
Patrick Molloy
Microsoft Excel MVP
 
Hi Tom
Thank you very much for your answer.
Since I was only looking for controls within the Worksheet Menu Bar,I
eventually found a "lighter" solution with the following:
For Each Cb In Application.CommandBars("Worksheet Menu Bar").Controls
If Cb.Caption = "Options &Cotation" Then
For Each Ctl In Cb.Controls
If Ctl.Type = 10 Then
For Each SousCtl In Ctl.Controls
If SousCtl.Tag Like "A*" Then
SousCtl.Enabled = True
End If
Next SousCtl
End If
Next Ctl
End If
Next Cb
Thanks again Tom
Regards
Pascal
 
Back
Top