Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Changing text in a label on userform

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    Tennessee
    Posts
    25
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi All:

    I'm using userforms now (thanks everyone for the help and ideas and would like to have the text in a label (Label2) change as the user changes data on the form.

    I.E.:
    When the form opens, Label2 = "Welcome to my form".

    After the user selects their name, Label2 = "Hello Dave, what would you like to do?"

    I tried the following code to set the label text when the form opens:

    Private Sub UserForm_Initialize()

    Startup_Form.Label2.Caption = Worksheets("List").Range("A65").Value

    End Sub

    When this code fires I get "Runtime error 9: Subscript out of Range"

    I'm using Rows A65-A75 (formated as text) to store data for the label.

    Any thoughts on what I'm doing wrong, or is there a better way to do this?

    Thanks

    Dave

  2. #2
    MrExcel MVP
    Join Date
    Apr 2002
    Location
    Vancouver BC , Canada
    Posts
    6,259
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This text does not have to be put in a cell , it can be hard coded in the form like this:
    Private Sub UserForm_Initialize()

    Startup_Form.Label2.Caption = " Welcome to my Form"

    Or you could type it directly into the Properties section of the Caption item for the object.

    If how ever you want to put it in a cell check the address your using since the error your getting indicates it's not finding the information you want to enter.

    End Sub

  3. #3
    New Member
    Join Date
    Mar 2002
    Location
    Tennessee
    Posts
    25
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Well, now I feel really stupid!! LOL

    Worksheets("List").Range("A65").value
    Should have been
    Worksheets("Lists").Range("A65").value

    I have been looking at and working on this monster WAAAAYYYY to long....

    Thanks

    Dave

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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