Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format a Textbox to percent

Status
Not open for further replies.

Jamie2002

Technical User
Sep 17, 2001
62
GB
I have got a textbox on a userform and it's control source is a cell on a worksheet.

The cell on the worksheet is formatted as % but the textbox is showing in decimal, ie

Cell 15.0%
Textbox 0.15

How can I show the textbox as a %'age.

Thanks.

 

How about this......


With Sheet1
TextBox1.Text = Range("a1")
TextBox1.Text = Format(TextBox1.Text, "0.0%")

End With
End Sub


Hope this helps unless there is a more suitable way.

Greg
 
Why wont this work ?


Private Sub UserForm_Activate()

TextBox1.Text = Format(TextBox1.Text, "0.0%")
TextBox2.Text = Format(TextBox2.Text, "0.0%")
TextBox3.Text = Format(TextBox3.Text, "0.0%")
TextBox4.Text = Format(TextBox4.Text, "£0.00")
TextBox5.Text = Format(TextBox5.Text, "0.0%")
TextBox6.Text = Format(TextBox6.Text, "0.0%")
TextBox7.Text = Format(TextBox7.Text, "0.0%")
TextBox8.Text = Format(TextBox8.Text, "0.0%")
TextBox9.Text = Format(TextBox9.Text, "0.0%")
TextBox10.Text = Format(TextBox10.Text, "0.0%")

End Sub

It only formats the currency field. ?!?!??
 
Hi Jamie.

Maybe you need to put e.g.

TextBox10.Text = Format(TextBox10.Text, "0.0" & "%")

HTH, DIW
 
this will get the %value from cell a1

ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Text = Str$(Cells(1, 1) * 100) + "%"
 
HELP !

When I set-up a simple userform1.show Excel is shutting down with the following error....

EXCEL caused an invalid page fault in
module OLEAUT32.DLL at 0167:653422fc.
Registers:
EAX=00033eb6 CS=0167 EIP=653422fc EFLGS=00010202
EBX=0000000d SS=016f ESP=0062da78 EBP=0062dab0
ECX=8b12eb02 DS=016f ESI=0062da9c FS=4357
EDX=305463a0 ES=016f EDI=0062000d GS=0000
Bytes at CS:EIP:
ff 51 08 66 c7 06 00 00 33 c0 5f 5e 5b c2 04 00
Stack dump:
00033eb6 0062da90 00000000 0181fe78 3047ddcc 0062da9c 0062dacc 0062daf8 3002c10c 0195000d 00000000 00033eb6 000000e0 65343d32 0062db14 3047de0b

How can I find out what this means ?

 
Hi

You probably don't. It probably means "this is a random error. Windows decided that you had gone too long without getting an error of some sort, so we just threw this rubbish together. Mwhhahahahahaha!"

Anywho, try putting:

Userform1.show
unload userform1
 
Jamie,

That information is generally for someone back in Microsoft who will determine exactly what is going on in the registers. It's not really user information. The OfficeXP suite prompts you to send a message to Microsoft when you get invalid page faults. The message includes the 'dump' that you have seen.

Steve King Growth follows a healthy professional curiosity
 
If you are still looking for a format solution for the TextBox try,
Code:
    Private Sub TextBox1_Exit(ByVal _
          Cancel As MSForms.ReturnBoolean)
        TextBox1 = [A1].Text
    End Sub
Where [A1] is the whatever cell you have set as the ControlSource.

AC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top