How can I display the textbox value in "%" format?
[vba]
.TextBox1.Value = c.Offset(0, 28).Value
[/vba]
How can I display the textbox value in "%" format?
[vba]
.TextBox1.Value = c.Offset(0, 28).Value
[/vba]
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
I believe it's something like this used in the Sub tetxbox1_change:
[vba]
Me.TextBox1.Value = Format(Textbox1.Value, "%")
[/vba]where Me will be the object it resides in, if you are using it in code not in the object module you need to specify the object i.e Userform1.TextBox1.....etc
Regards
Simon
Regards,
Simon
Please read this before cross posting!
In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
If I have seen further it is by standing on the shoulders of giants.
Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)
To change 15 to 15.00%
[VBA]Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.00%")[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
LOL i was close!
Regards,
Simon
Please read this before cross posting!
In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
If I have seen further it is by standing on the shoulders of giants.
Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)
Save data in the worksheet using TextBox1 (Perfect Code). Thanks "mdmackillop" for this code. It makes the user entry more easier.
[vba]
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.0%")
End Sub
[/vba]
But when I call back the data in the worksheet using TextBox1, 10% becomes 0.1 in the textbox happens when I used below code.
Call data from the worksheet using TextBox1
[vba]
.TextBox1.Value = c.Offset(0, 28).Value
[/vba]
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
[VBA].TextBox1.Value = Format(c.Offset(0, 28).Value ,"0.0%)[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
mdmackillop Perfect. Thanks
What about passing a null value with this code...Originally Posted by mdmackillop
[VBA]
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)[/VBA]
Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.0%")
End Sub
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
Use the text property [vba] .TextBox1.Value = c.Offset(0, 28).Text [/vba]
I have this code in the textbox. When I skip the textbox1 error come which is data type mismatch that made me into conclusion that skipping the textbox1 is not permitted. What I want to happen is a code if it's possible to skip textbox1 and entry to be made in textbox2.
[vba]
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.0%")
End Sub [/vba]
[vba]
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox2.Value = Format(TextBox2.Value / 100, "0.0%")
End Sub
[/vba]
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
[vba]
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.TextBox1
If .Value = "" Then
.Value = 0
End If
.Value = Format(.Value / 100, "0.0%")
End With
End Sub
[/vba]
xld ... this code works perfectly... once again thanks.
Originally Posted by xld
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.