• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Format TextBox as percentage

Belleke

Well-Known Member
Hi helpers,
I have a problem with textbox format in a userform.
Cell format in the sheet is percentage (0 decimals) (as example 15%)
I have this code to populate the textboxes in the userform
Code:
Private Sub ListBox1_Click()
...
TextBox18.Value = ListBox1.Column(22)
...
End sub
As example, in a cell I have 15%, but the textbox result in the userform is 0,15 afther the ListBox1 click event. Need some advice to populate textbox with 15% instead of 0,15.
Thank you in advance
 
Hi vletm,
Thank you for your reply (Jet airplane speed:p)
I fill an excelsheet with userform, no problem there
I use this code for the % TextBox
Code:
TextBox18.Value = Format(Val(TextBox18.Value) / 100, "#0%")
But sometimes some entries need to be changed, therefore I use the ListBox Click event to repopulate the textboxes where I can make some changes. And then I get 0,15 instead of 15% in the textbox, and afther saving the changes the cell with the % is also changed to 0,15 instead of 15 %, it should stay 15%
(15% is just an example, it can be 2% or 3% or ......etc.)
 
Belleke
Have You tried to use TextBoxN.Text instead of TextboxN.Value?
... or is it possible?
There are some challenges to test with just one code line.
... and if (of course) You're using some ActiveX-components then I cannot help.
 
Attached, the 2 files
If somebody has an idea to get rid of the calculation sheet "Tool"more then welcome.
 

Attachments

Try changing you after_update to:
Code:
Private Sub T_17_AfterUpdate()
T_17.Value = Format(Evaluate("VALUE(" & T_17.Value & ")"), "##.0%")
End Sub
 
I solved it with this code in the listbox click event.
Code:
Sheets("Tool").Range("B31") = LB_01.Column(22)
T_17.Text = Sheets("Tool").Range("B31").Text
Thanks, p45cal and vletm for your effort and time.
 
Belleke
... and one more possible would that
You would show that value*100 in Your Form and
then You'll save it - just remember to do value/100.
0.15 > do 0.15*100 > shows 15 >> after save to sheet >> 15/100 > back to 0.15
 
Back
Top