+ Reply to Thread
Results 1 to 5 of 5

Userforms - reset label to standard caption

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-11-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    136

    Userforms - reset label to standard caption

    Is there a "Default" Option for Labels in userforms?

    I have a Frame acting as a print preview, full of Labels that get populated by textboxes. I would like to be able to clear/reset/set Defaults for the Labels if needed, without unloading the whole userform.
    Any ideas?

    Thanks Michael

    Edit:
    By the way, at the Moment I can clear them completely by
    Dim ct As Msforms.Label
    For Each ct In fmAuftrag.Controls
    ct.Caption = ""
    Next ct
    but the of couse, the Default captions are also gone...
    Last edited by rodgersmg; 08-03-2015 at 05:15 AM.

  2. #2
    Forum Contributor
    Join Date
    10-11-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Userforms - reset label to standard caption

    I've got a temporary woraround at the Moment:
    Set the Label tag as the Default text and on reset
    Label.caption=Label.tag
    Would still be cool to know if there's a better way around it though

  3. #3
    Registered User
    Join Date
    09-24-2013
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Userforms - reset label to standard caption

    Try this

    Dim ct As Msforms.Label
    Dim counter as Integer
    counter = 1
    For Each ct In fmAuftrag.Controls
    ct.Caption = "Label" & counter
    counter = counter + 1
    Next ct

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Userforms - reset label to standard caption

    I think using the tag option is fine, why do you want another solution?

  5. #5
    Forum Contributor
    Join Date
    10-11-2013
    Location
    Austria
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Userforms - reset label to standard caption

    I thought maybe there was some form of "default" setting for a label, as with some other controls. Like a control.clear sort of deal..
    hudibyk your solution would also be great, except every label has a text in the caption by default, rather than just Labelx

    I'll run with the tags for now!
    Edit:
    Had to run it like this, otherwise it tried to set all controls instead of just labels
    Private Sub CommandButton2_Click()
    Dim lbl As MSForms.Control
    
    For Each lbl In UserForm1.Controls
    If TypeOf lbl Is MSForms.Label Then
    lbl.Caption = lbl.Tag
    End If
    Next lbl
    
    
    End Sub
    Last edited by rodgersmg; 08-03-2015 at 11:29 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Use API to disable or hide the Close Button or Caption Bar on UserForms
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-25-2014, 09:33 PM
  2. [SOLVED] Change Label Caption VB...
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2013, 09:17 AM
  3. [SOLVED] Label caption
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-25-2013, 09:31 AM
  4. New Sum and label caption not working
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2011, 11:46 AM
  5. Display label caption
    By Nancy123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-04-2010, 07:49 AM
  6. Reset a caption for a Pivot Table
    By douglascfast@hotmail.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-18-2005, 11:05 AM
  7. [SOLVED] label caption equal excel value
    By Ian in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  8. label caption equal excel value
    By Monique in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1