+ Reply to Thread
Results 1 to 6 of 6

Text box in form

  1. #1
    Registered User
    Join Date
    10-24-2005
    Posts
    55

    Text box in form

    Hi guys

    I have a text box in a user form that take is linked to sheet1! G3

    But G3 had the formula that works out the prices from different sheets and show the answer. I can only seem to use the text box once it shows the number but Deletes the formula and just leaves the figure in the cell G3 I just need the text box as a display box?

    Also i can not seem to get the text box to display £ and the 0 on the end of pence e.g. 123.1 and it should be £123.10

    Thanks for your help
    Last edited by raw; 10-26-2005 at 01:15 PM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good evening raw

    We can solve both of these with one line of code:

    TextBox1.Text = Format(Range("Sheet1!G3").Value, "£#,###.00")

    However, this is probably a bit of a diversion to the way you've probably done it, especially if you've linked the textbox to the value property, but this is the better way to go.

    If you struggle to implement this post back and we'll take it from there.

    HTH

    DominicB

  3. #3
    Registered User
    Join Date
    10-24-2005
    Posts
    55

    Hi

    Hi Thanks for the code

    This maybe a stupied question but where do you put this code?

    Thanks

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi raw

    Well, it really depends on how your spreadsheet is set up.

    Say, you're using UserForm1 and your textbox is called TextBox1 and you have a macro calling Userform1:

    Sub Test()
    UserForm1.Show
    End Sub

    From the VBE double click on the UserForm you've designed and copy this code into the pane that opens:

    Private Sub UserForm_Initialize()
    TextBox1.Text = Format(Range("Sheet1!G3").Value, "£#,###.00")
    End Sub

    Now, when you run the macro "Test", UserForm1 should open and TextBox1 will contain the value of G3 formatted in £ and pence.

    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    10-24-2005
    Posts
    55

    Thanks

    Hi Thanks for that

    Worked

    Thank you

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi raw

    You're welcome. Thanks for the feedback.

    DominicB

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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