+ Reply to Thread
Results 1 to 12 of 12

Getting a specific Number Format in a TextBox of a UserForm

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Getting a specific Number Format in a TextBox of a UserForm

    Dear Gurus,

    I am trying to get a specific Number Format which I always use for currency in all my files, I have created a user form and I need to get the same format in the user form however I am unable to do so..
    My Number format is text starting with "Rs " and then followed by numbers with the commas at the desired places...Whiles googling I found something more interesting in the below link which formats while entering the text however I am not able to have the benefits of both..

    My Number Format -
    Please Login or Register  to view this content.
    The LINK -
    HTML Code: 
    The Code I tried to tweak unsuccesfully.

    Please Login or Register  to view this content.
    Can someone please advise or help me on this code I want the Text in the TextBox as Number to be added seperately in the excel file where the contents would be saved.

    Thanks in advance...God bless...

    Warm Regards
    e4excel

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Getting a specific Number Format in a TextBox of a UserForm

    What's with the \ in the number format? I didn't know that the Rupees had a \ in it's format
    Last edited by Keebellah; 01-23-2017 at 11:04 AM.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a specific Number Format in a TextBox of a UserForm

    Its just the separator I too had found this solution on the net...

    Please Login or Register  to view this content.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Getting a specific Number Format in a TextBox of a UserForm

    The backslash indicates that what follows- a comma in this case- should be treated as a literal character.

    I would suggest using the Exit or BeforeUpdate event of the textbox for the formatting rather than the Change event if possible.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a specific Number Format in a TextBox of a UserForm

    I want the Text in the TextBox to display Rs but while getting saved in the Excel Sheet it should just be a number which can be used for any mathematical operation..

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Getting a specific Number Format in a TextBox of a UserForm

    When your code writes the value to a cell you need only replace the formatting characters you added.

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Getting a specific Number Format in a TextBox of a UserForm

    If you ste the cells format to Custom and paste this in it, the value will be without the characters

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a specific Number Format in a TextBox of a UserForm

    I have used the code in my first code which I found however I wanted to combine the best of the original code with this format for Rupees as well as retaining the Number Value in the excel sheets for performing Mathematical Operation...

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Getting a specific Number Format in a TextBox of a UserForm

    With the format code I indicated all you need to do is to past the numeric value form the textbox (without the Rs) into the cell. The formatting will display the Rs but there is no text in the cell, just numbers.

  10. #10
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a specific Number Format in a TextBox of a UserForm

    I am unable to follow what you are trying to suggest ..I tried the code in the AfterUpdate it displays the text with the Rupees however gets entered as Text so no math operations can be performed.

    Please Login or Register  to view this content.
    I want to have the dual advantage of displaying it with Rupees as well as that being stored as a number when entered in a cell...

    Please provide the code if possible... I think the NumberFormat is not a TextBox Property so if there's any other workaround which I am not aware of please suggest the same or the code...

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Getting a specific Number Format in a TextBox of a UserForm

    Do you have the textbox linked directly to the cell? If you do, you cannot have what you want. You must use code to write the value to the cell after removing the formatting.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Getting a specific Number Format in a TextBox of a UserForm

    True, but maybe you could it another way.
    Is it possible you attach a sample workbook with the routine, some non-sensitive data would help, makes it easier to test under the conditions you are using it.

+ 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] Excel 2010 - Userform - display date from textbox in a label or textbox in 'ddd' format
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2015, 10:54 PM
  2. [SOLVED] Excel 2007, Userform Textbox Date Format and Calendar Control Userform
    By riffology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2014, 06:18 PM
  3. [SOLVED] UserForm Textbox Specific Format
    By AlexRoberts in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2010, 08:29 AM
  4. Code to format number input in textbox controls (based on tag) in userform
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-05-2010, 01:09 PM
  5. format a TextBox on a userform
    By randyvann in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-20-2008, 05:14 PM
  6. [SOLVED] Goto Specific Textbox in Userform
    By Kris_Wright_77 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2005, 11:05 AM
  7. [SOLVED] Format of a TextBox in a userform
    By MD in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2005, 02:06 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