Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 193
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 193
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm TextBoxes - Is there a way to format as currency or perce Terry Excel Discussion (Misc queries) 0 September 11th 08 06:27 PM
how do i format a textbox on a userform created in excel Bert New Users to Excel 1 May 5th 08 11:46 PM
Need A date Mask format for a Textbox on UserForm [email protected] Excel Discussion (Misc queries) 2 November 4th 07 02:27 AM
Currency Format on UserForm when opened! Robo[_2_] Excel Discussion (Misc queries) 3 May 8th 07 02:42 PM
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM


All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"