ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   format cell reference in a text box (https://www.excelbanter.com/excel-programming/385253-format-cell-reference-text-box.html)

tbone

format cell reference in a text box
 

How do I format the resulting number that is displayed in a text box? I
have used the linked cell property to define that cell C17 is what appears in
the text box. Cell C17 is a percentage. Currently it will display as
3.3333333333333E-2 for 3.33%. I would like it to appear in the text box as
3.33%. How do I limit the decimal places and add the % sign?

Thanks

Tom Ogilvy

format cell reference in a text box
 
Use the change event to reformat the textbox:

Private Sub Textbox1_Change()
Textbox1.Value = Format(Textbox1.Value,"0.00%")
End Sub


--
Regards,
Tom Ogilvy

"Tbone" wrote:


How do I format the resulting number that is displayed in a text box? I
have used the linked cell property to define that cell C17 is what appears in
the text box. Cell C17 is a percentage. Currently it will display as
3.3333333333333E-2 for 3.33%. I would like it to appear in the text box as
3.33%. How do I limit the decimal places and add the % sign?

Thanks


tbone

format cell reference in a text box
 
Thanks that did it!

"Tom Ogilvy" wrote:

Use the change event to reformat the textbox:

Private Sub Textbox1_Change()
Textbox1.Value = Format(Textbox1.Value,"0.00%")
End Sub


--
Regards,
Tom Ogilvy

"Tbone" wrote:


How do I format the resulting number that is displayed in a text box? I
have used the linked cell property to define that cell C17 is what appears in
the text box. Cell C17 is a percentage. Currently it will display as
3.3333333333333E-2 for 3.33%. I would like it to appear in the text box as
3.33%. How do I limit the decimal places and add the % sign?

Thanks



All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com