Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default What does the Userform.Tag do?

I am curious what the Tag part of a Userform is for?
--
Thanks, Brad E.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default What does the Userform.Tag do?

Hi,

The help files says,

Stores additional information about an object.

Syntax

object.Tag [= String]

The Tag property syntax has these parts:

Part Description
object Required. A valid object.
String Optional. A string expression identifying the object. The default
is a zero-length string ("").


Remarks

Use the Tag property to assign an identification string to an object
without affecting other property settings or attributes.

For example, you can use Tag to check the identity of a form or control
that is passed as a variable to a procedure.

Cheers
Andy

On 05/03/2010 12:51, Brad E. wrote:
I am curious what the Tag part of a Userform is for?


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default What does the Userform.Tag do?

The Tag property is String that can be used for anything you wish to help
identify any control. Most controls have them. To me it's kinda used as a
built in custom univerisal property.

In your case for example, lets say you have 3 userforms. Userfrom1 and
Userform2 have the Tag property set to "Run Code". Userform3 has nothing as
a Tag. Now lets say you want to run a procedure for all userforms with Tag =
"Run Code". You would put this in the Initialize Event of each userform.

Private Sub UserForm_Initialize()
If Me.Tag = "Run Code" Then Call MySub
End Sub

Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"Brad E." wrote:

I am curious what the Tag part of a Userform is for?
--
Thanks, Brad E.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default What does the Userform.Tag do?

I've seen some code where it's used as (essentially) a variable to pass
information back to the routine that loaded and showed the userform.

For instance, I created a userform with two commandbuttons and a single
checkbox.

This was the code behind the userform:

Option Explicit
Private Sub CommandButton1_Click()
Me.Tag = "cancel"
Me.Hide
End Sub
Private Sub CommandButton2_Click()
Me.Tag = "ok"
Me.Hide
End Sub
Private Sub UserForm_Initialize()
Me.CommandButton1.Caption = "Cancel"
Me.CommandButton2.Caption = "ok"
End Sub

Then I loaded the userform (and read the results) in this code in a General
module:

Option Explicit
Sub testme()

Dim UF1 As UserForm1

'load the userform
Set UF1 = New UserForm1

UF1.Show

If UF1.Tag = "ok" Then
MsgBox UF1.CheckBox1.Value
Else
MsgBox "User hit cancel, don't trust the checkbox!"
End If

Unload UF1

End Sub

But you could use it to pass any other info to the userform, too--maybe a string
that initializes a textbox????


Brad E. wrote:

I am curious what the Tag part of a Userform is for?
--
Thanks, Brad E.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fill userform textbox from userform listbox clik event GregJG[_21_] Excel Programming 3 December 7th 08 04:47 PM
Is there an easy Copy/Paste of a Userform ? (Entire Userform Including tx & cbx's) Corey Excel Programming 2 January 9th 07 01:01 PM
Userform to enter values and shown in same userform in list helmekki[_104_] Excel Programming 0 November 19th 05 03:23 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM


All times are GMT +1. The time now is 10:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"