Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    User Form Caption (Excel 2000)

    I am using Excel's Visual Basic Editor to create a User Form and would like to add a variable to a Label caption. Is this possible? Something like: Your entry does not match the worksheet value of myVar is this correct?

    In this case I would prefer the User Form to a Message Box.
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: User Form Caption (Excel 2000)

    You can set the caption of a label in code, for example in the Initialize event of the userform.

    Private Sub UserForm1_Initialize()
    Me.Label1.Caption = "Your entry does not match " & myVar & ". Is this correct?"
    End Sub

    or

    Private Sub UserForm1_Initialize()
    Me.Label1.Caption = "Your entry does not match " & Worksheets("Sheet1").Range("C37").Value & ". Is this correct?"
    End Sub

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Form Caption (Excel 2000)

    Yes, like this:

    sStr="And This Is A Variable Part Of The Caption"
    Userform1.Caption="This Is The Caption Of This Form " & sStr

    ########edited: misread the question##############

    Oh well, at least this shows you how to change the caption of the form itself
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  4. #4
    New Lounger
    Join Date
    Aug 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Form Caption (Excel 2000)

    Thanks Hans that worked just perfect!

Posting Permissions

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