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?
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Tinbendr

Well-known Member
Joined
Jul 21, 2010
Messages
997
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, "#,###")
 

ktorres

New Member
Joined
Jan 12, 2016
Messages
4
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,701
Messages
5,524,405
Members
409,575
Latest member
navarrov74

This Week's Hot Topics

Top