![]() |
TextBox on a userform - format to currency & percent
I have a userform with a textbox named Amount & another one named Rate is
there a way to format these textboxs as Currency and Percent? Thanks Terry |
TextBox on a userform - format to currency & percent
There is no edit mask that you could apply, but you could change the format each
time you leave the textbox. Option Explicit Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) With Me.TextBox1 If IsNumeric(.Value) Then .Value = Format(.Value, "$#,##0.00") Else 'keep them in the textbox Cancel = True Beep End If End With End Sub If you to allow the users to hit the cancel key (if you have one) with an invalid entry in the textbox, then make sure that cancel key has its ..takefocusonclick property set to false. Terry wrote: I have a userform with a textbox named Amount & another one named Rate is there a way to format these textboxs as Currency and Percent? Thanks Terry -- Dave Peterson |
TextBox on a userform - format to currency & percent
Thanks Dave Works great - Terry
"Dave Peterson" wrote: There is no edit mask that you could apply, but you could change the format each time you leave the textbox. Option Explicit Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) With Me.TextBox1 If IsNumeric(.Value) Then .Value = Format(.Value, "$#,##0.00") Else 'keep them in the textbox Cancel = True Beep End If End With End Sub If you to allow the users to hit the cancel key (if you have one) with an invalid entry in the textbox, then make sure that cancel key has its ..takefocusonclick property set to false. Terry wrote: I have a userform with a textbox named Amount & another one named Rate is there a way to format these textboxs as Currency and Percent? Thanks Terry -- Dave Peterson |
All times are GMT +1. The time now is 02:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com