+ Reply to Thread
Results 1 to 12 of 12

Curency format in textboxes of userform

  1. #1
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Curency format in textboxes of userform

    Hello

    I have a userform that one textbox takes it's value from a cell in sheet3.(k2). The format of this cell is currency. How the textbox takes the same format as the cell?

    In the same userform i have a series(prcase1,prcase2..) of textboxes that i want to have currency format as the user type numbers on these.

    How can i do this?

    Thanks in advance for any assistance here.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Curency format in textboxes of userform

    Hi something like

    Please Login or Register  to view this content.
    Note that current k2 number format is not currency, but some custom number format. More general approach will be

    Please Login or Register  to view this content.
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Re: Curency format in textboxes of userform

    Thank you. Both suggestions work.

    Any idea for my second question?

    ...In the same userform i have a series(prcase1,prcase2..) of textboxes that i want to have currency format as the user type numbers on these.

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Curency format in textboxes of userform

    sorry, I missed that :-)
    It will require some code in the AfterUpdate event of the textbox, that will format the user input. Instead my personal choice would be to have label after the textbox where I would display currency sign. Of course that depends on what you will do with the user input.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Curency format in textboxes of userform

    Maria. Use the Exit Event to format eatch one of your textboxes .

    Please Login or Register  to view this content.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

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

    Re: Curency format in textboxes of userform

    If you want the value in K2 as it's formatted on the sheeet use it's Text property.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  7. #7
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Re: Curency format in textboxes of userform

    Mr Norie

    Thank you for your suggestion. What i need for textbox1, is what buran suggested in post#2.

    Mr Fotis

    Yes. This works(as all your suggestions) perfectly. Thank you very much.

    I am just wondering if there is a solution to format ALL prcase textboxes at once. You see in some of my userforms i have 30 like these...and it's really hard to do it one by one..

  8. #8
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Curency format in textboxes of userform

    Maria, as usual there is more than one way to go from A to B. Mr. Nirie suggestion works just fine. I don't use Text property of the Range object often, but it's 100% correct solution too. It's a matter of choice which method one will use.

    It's possible to format all prcase textboxes with single piece of code, but it will require custom class. I'll try to make an small example within your file

  9. #9
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Re: Curency format in textboxes of userform

    No no no...You have missunderstoond my words(or my English...? )buran. I hope Mr Norie didn't!!

    I am too young and also with limited Excel KNOWLEDGE. So in no case i am not able to say to a great Excel Guru(Not just Forum Guru) like Mr Norie that his suggestion does not works. I wanted just to say that your suggestion works great for me.

    I really apologize for the missundertanding.

    I'll be waiting to see your new suggestion. Thank you!

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Curency format in textboxes of userform

    I am sure that Mr Norie understands the difficulties of using another launquge Maria. Don't worry!

  11. #11
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Curency format in textboxes of userform

    Maria, find attached file. Unfortunately, it seems that in class module TextBox control does not support all of the events. So it's not possible to use AfterUpdate event. I had to find workaround, so textbox are being formatted as Currency, after mouse move event or when tab or arrow key is pressed.
    That's maybe not the best solution, but that's what I can do. At least you will see the idea...
    Attached Files Attached Files

  12. #12
    Forum Contributor MariaPap's Avatar
    Join Date
    10-19-2013
    Location
    Chania-Crete-Greece
    MS-Off Ver
    Excel 2003-2010
    Posts
    319

    Re: Curency format in textboxes of userform

    Thank you so much!! Too much work! I really appreciate it!!
    .. Unfortunately, it seems that in class module TextBox control does not support all of the events.
    Too pitty..!In this case it would be perfect..

    So i think that i have to mark this as solved!

    Thanks agin all threee of you!

+ 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. Help Populating Textboxes in Userform, With Multipage Userform.
    By mdmorgan24 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2012, 05:29 PM
  2. Is there a way to format all TextBoxes on a UserForm the same at one time?
    By D3Pratt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2009, 09:09 AM
  3. Userform TextBoxes
    By tqm1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2007, 09:04 AM
  4. UserForm TextBoxes
    By Rob in forum Excel General
    Replies: 2
    Last Post: 08-05-2005, 10:07 PM
  5. Changing all textboxes on a userform
    By Mat K in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2005, 06:54 PM

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