Number format in userform

TheShaunMichael

Board Regular
Joined
Oct 24, 2009
Messages
57
I have a userform and when you click the "Okay" command button, my spread sheet is populated with the numbers from the form but I can't get the number format correct. I've tried cell(x, y).number = so on and so forth but it doesn't work. I believe it's populating as a "General" entry in the cell.

I need the numbers in accounting format please!

At the same time, how do I add an input mask on the userform so when someone inputs a number in the textbox a comma get's added appropriately?

Thank you!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,

Try this

Rich (BB code):
Private Sub CommandButton1_Click()
    Range("A1").Value = Format(TextBox1, "$#,##0.00")  'Or instead of Range("A1").Value you can use Cells(1, 1).Value
End Sub

Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox1.Value = Format(TextBox1, "#,##0.00")
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,783
Messages
6,132,684
Members
449,748
Latest member
freestuffman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top