Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number format in vba
I have the following code for passing some data on to a user form:
Private Sub UserForm_Initialize() Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Value End Sub Works fine except for one thing - I am getting a number in my text box that has 12 decimal places. How do I format so the value returned only has 2 decimals? Regards gregork |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number format in vba
|
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number format in vba
You could control the format explicitly, like:
Me.TextBox1.Value = format(Sheets("Blend Sheet").Range("ac7").Value,"0.00") or you could pick up what's displayed in the worksheet: Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Text gregork wrote: I have the following code for passing some data on to a user form: Private Sub UserForm_Initialize() Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Value End Sub Works fine except for one thing - I am getting a number in my text box that has 12 decimal places. How do I format so the value returned only has 2 decimals? Regards gregork -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number format in vba
one way:
Me.TextBox1.Value = Format(Sheets("Blend Sheet").Range("ac7").Value, _ "0.00") In article , "gregork" wrote: I have the following code for passing some data on to a user form: Private Sub UserForm_Initialize() Me.TextBox1.Value = Sheets("Blend Sheet").Range("ac7").Value End Sub Works fine except for one thing - I am getting a number in my text box that has 12 decimal places. How do I format so the value returned only has 2 decimals? Regards gregork |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do I add phone number format as a permanent custom format? | Excel Discussion (Misc queries) | |||
Replace million-billion number format to lakhs-crores format | Excel Discussion (Misc queries) | |||
Change number (in text format) to numeric format | Excel Discussion (Misc queries) | |||
convert text-format number to number in excel 2000%3f | Excel Discussion (Misc queries) | |||
excel format cells/Number/Category: Number problem | Excel Discussion (Misc queries) |