Updating .tag in Userform Control in VBA

  • Thread starter Thread starter Chan
  • Start date Start date
C

Chan

I am trying to adjust the tag property of approx. 150
different controls in a userform using a list from an
excel spreadsheet. I wrote the following code to do this:

For Each Ctl In Main.Controls
With Range("Controls")
Set x = .Find(Ctl.Name, lookat:=xlWhole)
If Not x Is Nothing Then
Ctl.Tag = x.Offset(0, 1).Value
End If
End With
Next Ctl

--"Controls" is the list of controls with the tag I want
entered in the neighboring column

If I step through the code, it seems to pull information
correctly...I am able to see which control is being pulled
up, what the value of the tag should be set to, even the
Ctl.Tag seems to correct...but for some reason, the tag is
not adjusted in the form when the macro finishes.

Anyone have any ideas?
 
Chan,

No you will never change the default state of the tags in code, but by
putting it in the initialize event it will always be there whilst the form
is active. The other thing is to hide the form not unload it as suggested,
that way even if the form is not visible it is in memory and the tags will
persist for the time.
 
Back
Top