vba userform textbox formatting

ktorres

New Member
Joined
Jan 12, 2016
Messages
4
How can I maintain decimals in a textbox but only display in this format: "#,###"?

For example, the user inputs a cost estimate of 1,300 for the year so the Jan - Dec text-boxes are populated with 108 but the real number is 108.3333 but when I have the textbox save the data back in the spreadsheet it is only saving 108. Any ideas?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
No. Textbox boxes are strings and however you display them is their value. However, you can store the value in the Tag property, then format the Tag property to the textbox.

Code:
Me.TextBox1.Tag = MyNum
Me.TextBox1 = Format(MyNum, "#,###")
 
Upvote 0
No. Textbox boxes are strings and however you display them is their value. However, you can store the value in the Tag property, then format the Tag property to the textbox.

Code:
Me.TextBox1.Tag = MyNum
Me.TextBox1 = Format(MyNum, "#,###")


Thanks! I ended up using a more complicated work around by calling the calculate sub then saving the data so the user will see the nice numbers but the model saves the exact number.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,245
Members
448,555
Latest member
RobertJones1986

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