Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: userform question

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    382
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have cell J52, how can I have a textbox on a userform display that cells data?

    Thanks in advance.
    I appreciate the help from everyone at Mr. Excel.

    viper

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Assuming your textbox is named TextBox1

    TextBox1.Text = Sheets(YourSheetName).Range("J52")

    Or

    TextBox1 = Range("J52")

    Tom

  3. #3
    Board Regular
    Join Date
    May 2002
    Location
    Dallas
    Posts
    366
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    How about the other way? I'm new to user forms, and I've got a text box in one of them that I'd like to have the string written into it posted into a designated cell when the user form is submitted. Any thoughts?

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    382
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Assumming you want cell A1 to contain the data from your textbox.

    right click on your command button on your userform, click view code.
    In the command button click_event write.
    Range("A1") = TextBox1.value

    Thats all.
    I appreciate the help from everyone at Mr. Excel.

    viper

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    382
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thank you works great. But how do I change the format of how it shows the data? Right now it shows -.229 and I need for it to show -22.9. I tried the code above and added * 100 to the end but that produced an error. I have placed ##.##% in the text value under the textbox properties but it didn't work.


    I appreciate the help from everyone at Mr. Excel.

    viper

  6. #6
    Board Regular
    Join Date
    May 2002
    Location
    Dallas
    Posts
    366
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Fantastic! Works like a charm.

    Thanks.
    - Thomas

  7. #7
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    What is the value in the cell?
    Tom

  8. #8
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try this...

    TextBox1.Text = Format(Range("J52"), "##.##%")

    Tom

  9. #9
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    382
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks,
    I tried it but it gave me a error.

    The cell contains a percent (22.9). In order for my textbox to show any value I have placed my code in the userform initialize event.
    Textbox1.text = sheets("sheet 5").Range("J74")

    As long as I keep that code the textbox shows the value 0.229, but I need for it to show 22.9. I have placed the above code in the textbox_change event but the textbox was blank when opened. If I try and write a format code in the textbox_change event it comes up blank.

    Any other ideas?


    I appreciate the help from everyone at Mr. Excel.

    viper

  10. #10
    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 worked for me :

    Private Sub UserForm_Initialize()
    TextBox1.Text = Val(Sheets("sheet 5").Range("J74")) * 100
    End Sub

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
  •