Can I use VBA to change name and controlsource
this is a basic loop-thru code for a userform:
Dim oControl As Control
For Each oControl In Me.Controls
If TypeOf oControl Is msforms.CheckBox Then
oControl.Value = True
End If
Next oControl
if you put it in the userform_initialize sub (only for the first time;
take it out after that) you could ammend it & for each one do:
oControl.Name=" whatever"
oControl.ControlSource="whatever"
this is not tested.
hth
susan
On Mar 5, 1:06 pm, "hdf" wrote:
I have an user form that has 20 check boxes. I have duplicated it
several times by copying it in from another worksheet. I now need to
change the name of each check box in the new UserForms and the
controlsource for each. Is there a way to do this throuhg vba code.
For example; I have UserForm1 and it contains 20 check boxes named:
ChkBx_uf1_1...ChkBx_uf1_20
and the controlsource for each is a range:
ChkBxA_Link1...ChkBxA_Link20.
For each new User Form I have created (copied) I need to change the
names of the check boxes and the controlsources. So, UserForm2 would
have ChkBx_uf2_1...ChkBx_uf2_20 and the controlsources would be
ChkBx_uf2_Link1...ChkBx_uf2_20.
I've tried several approaches, but am getting nowhere.
Any help greatly appreciated.
|