ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA currency or percent format object (https://www.excelbanter.com/excel-programming/431086-vba-currency-percent-format-object.html)

cwsimmons

VBA currency or percent format object
 
I have created a UserForm in VBA and would like users to enter currency and
percent values and see them formated as such. I can find only the TextBox
object in the Toolbox, which does not display inputs in the desired format.
Is there an object somewhere that automatically formats user inputs as
currency or percents?

ryguy7272

VBA currency or percent format object
 
It's going to be something like this:

Private Sub UserForm_Click()
If TextBox1.Text < "" Then
TextBox1.Text = Format(CDbl(TextBox1.Text), "$#,##0.00")
End If


If TextBox1.Text < "" Then
TextBox1.Text = Format(CVar(TextBox1.Text), "##0.00%")
End If
On Error Resume Next
End Sub

HTH,
Ryan

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"cwsimmons" wrote:

I have created a UserForm in VBA and would like users to enter currency and
percent values and see them formated as such. I can find only the TextBox
object in the Toolbox, which does not display inputs in the desired format.
Is there an object somewhere that automatically formats user inputs as
currency or percents?



All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com