+ Reply to Thread
Results 1 to 6 of 6

UserForm TextBox formats - Display as Decimal, Read as Percent. Possible?

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Question UserForm TextBox formats - Display as Decimal, Read as Percent. Possible?

    I have a TextBox on a UserForm.

    I want the end users to enter a % in this box.

    If the end user enters a decimal, I want the value to be automatically converted to a % (macro change event)

    However when the End User presses the Save command button on the form, I want this same text box value to be read as a decimal.

    Is this possible?
    Last edited by mc84excel; 05-12-2013 at 08:35 PM. Reason: typo in thread name
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: UserForm TextBox formats - Display as Decimlal, Read as Percent. Possible?

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm TextBox formats - Display as Decimlal, Read as Percent. Possible?

    Thanks +1

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm TextBox formats - Display as Decimal, Read as Percent. Possible?

    Just an update. I had some issues with trying to get the code work in real life. I have edited the code so the userform checks/returns the values by a custom function. Below is what I have come up with. It has errors (which are noted in the comments)...

    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: UserForm TextBox formats - Display as Decimal, Read as Percent. Possible?

    Quote Originally Posted by mc84excel View Post
    ' if entering decimals, only allows increments of 10% (annoying - needs to be fixed)
    If you enter .02 you get 02.0% returned. If you enter .2 you get 20.0% returned. Isn't that correct?

    Change this "00.0%" to this "0.0%" to remove the leading zero.

    You could enter decimal values like .002 and get 0.2% returned.

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: UserForm TextBox formats - Display as Decimal, Read as Percent. Possible?

    Quote Originally Posted by AlphaFrog View Post
    If you enter .02 you get 02.0% returned. If you enter .2 you get 20.0% returned. Isn't that correct?

    Change this "00.0%" to this "0.0%" to remove the leading zero.

    You could enter decimal values like .002 and get 0.2% returned.
    Thanks again AlphaFrog.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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