+ Reply to Thread
Results 1 to 22 of 22

Can't get a userform text box to display a number format, ie "Currency"

  1. #1
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Can't get a userform text box to display a number format, ie "Currency"

    I am creating a userform that will take inputs and then calculate a number of different results. Some results will be in number format and other I would like currency(US) format. I have tried to format the controlsource cell and used this statement, my textbox in this example is txtBasePay. txtBasePay.Value = Format(txtBasePay.Value, Evaluate(txtBasePay.ControlSource).NumberFormat) but that hasn't worked. I have tried simple formatting code like txtBasePay = Format (BasePay, "Currency") without success.

    Greg

  2. #2
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Actually the above Sub should read txtBasePay.Value = Format(BasePay.Value, Evaluate(BasePay.ControlSource).NumberFormat)

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  4. #4
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Thank you Stnky, but the box does update correctly to a new value when I change input but the format is not shown.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Can't get a userform text box to display a number format, ie "Currency"

    the box does update correctly to a new value when I change input but the format is not shown.
    I don't understand what you want then

  6. #6
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    I would like my text box to show "$10.00" instead of 10

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Don't use ControlSource to populate the textbox.

    How are you doing the calculation and where do the inputs come from?

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.
    If posting code please use code tags, see here.

  8. #8
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Can't get a userform text box to display a number format, ie "Currency"

    I would like my text box to show "$10.00" instead of 10
    It does exactly this when I run the code I supplied. Submit an example workbook.

  9. #9
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    I have attached a striped down version. The only textbox I have coded is BasePay. But I am going to need formatting for others as this will grow.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    I have uploaded a workbook. I have been away from Excel for a little over two years and just getting back to it. I have used userforms before but never wanted to format the shown result in the textbox. For instance b4 has hours worked from userform input and b5 hourly pay from userform input and then a textbox that will show b4*b5 in currency.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Don't use ControlSource, use code to populate the textboxes on the userform and to do the calculations/formatting.

  12. #12
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    The userform works. I need user input and have no idea how to code that. I just wanted to have number formatting.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can't get a userform text box to display a number format, ie "Currency"

    What do you mean by 'user input'?

    Input via the userform? Or input on a worksheet?

  14. #14
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    A user would type in his or her hours worked in those text boxes. There is other input from users but it text based, ie name.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can't get a userform text box to display a number format, ie "Currency"

    If that's what's happening there's no need to use ControlSource.

  16. #16
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    I am confused then. I need to get hours and other information to make calculations and then display the results in a textbox in that userform. If I don't direct the user input to a cell with controlsourse I have no idea how it gets there then.
    Last edited by Gwg1955; 11-06-2015 at 11:15 AM.

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Hi Gwg1955

    What's the purpose of the User Form?

    Why not enter the Data directly into the User Form?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  18. #18
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    I am entering data into a user form. IE text box for name. hours worked, hourly pay rate, then the userform will return in other textboxes the pay, the whithholding ect. So for example the user inputs hours into taxtbox1 and pay rate in textbox 2 and in textbox 3 appears his pay. In textbox 3 I would like it to be formatted to currency. I also need other boxes to be fomatted in number with 2 decimal places. The user will not have access to the worksheet that the textbox controlsource is linked to.

  19. #19
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Hi Gwg1955

    This Code is in the attached UserForm...see if it approaches what you're trying to do. Click the Button.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Yes jaslake the downloaded xlsm does what I want. Thank you! Now I have a lot of code to write....

  21. #21
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can't get a userform text box to display a number format, ie "Currency"

    Hi Gwg1955

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    If this resolves your issue please mark your Thread as SOLVED.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

    If you need further help let us know.

  22. #22
    Registered User
    Join Date
    11-04-2015
    Location
    NH
    MS-Off Ver
    2012 With VBA 7.1
    Posts
    13
    Quote Originally Posted by jaslake View Post
    Hi Gwg1955

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    If this resolves your issue please mark your Thread as SOLVED.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

    If you need further help let us know.
    Can't figure that out on my phone, have to wait till tomorrow. Thanks again.

+ 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] format change "general" to "currency" ($)
    By k1dr0ck in forum Excel General
    Replies: 5
    Last Post: 09-10-2015, 05:52 AM
  2. Display "TEXT" in "Values" field in PIVOT TABLE using VBA!!
    By meus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2015, 09:56 AM
  3. Date format of just "st" "nd" "rd" and "th" with text included
    By notrandom in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-10-2013, 05:45 PM
  4. Customising the TEXT(Value,"Format") Function for Indian Currency
    By e4excel in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-11-2011, 10:43 AM
  5. Changing format of column from "general" to "currency"
    By Old Car in forum Excel General
    Replies: 1
    Last Post: 04-29-2005, 05:06 AM
  6. Changing format of column from "general" to "currency"
    By Old Car in forum Excel General
    Replies: 1
    Last Post: 04-29-2005, 05:06 AM
  7. Changing format of column from "general" to "currency"
    By Old Car in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2005, 05:06 AM

Tags for this Thread

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