• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Using the textbox tag property

Belleke

Well-Known Member
I want to fill all the textboxes in a userform that have a tag Yes with Date
Something like
Code:
Private Sub UserForm_Initialize()
For Each Ctrl In Controls
    If Ctrl.Tag = "Yes" Then Ctrl.value=format(Date,"dd-mm-yyyy")
next Ctrl
end sub
thanks in advance
 
If you have other control types that might have a Yes tag that you want to exclude, then test the type:

Code:
PrivateSub UserForm_Initialize()
For Each Ctrl In Controls
   If TypeOf Ctrl Is MSForms.Textbox and Ctrl.Tag = "Yes" Then Ctrl.value = format(Date,"dd-mm-yyyy")
next Ctrl
end sub
 
Hi Yaser and Debaser, thanks for the quick reply.
The combination of both answers did the trick.
I tryed the code of debraser this morning but without MSForms
Did't work.
I tryed Yasser sugestion
Didn'work
But the combination of both works
Using MSforms in the code and using integer as tag.
My problem is solved.
Have a nice day.
 
Back
Top