ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform Textbox Format to fraction (https://www.excelbanter.com/excel-programming/394613-userform-textbox-format-fraction.html)

[email protected]

Userform Textbox Format to fraction
 
Is there a way to make it so a userform textbox will only display
fractions ?

For Example:

If TextBox1 = A1 when the userform is activated and A1 has a value of
1.5 I want the textbox to show 1 1/2 . Any help on this would be
greatly appreciated.

Thanks


Dave Peterson

Userform Textbox Format to fraction
 
If the cell is formatted nicely:

Option Explicit
Private Sub UserForm_initialize()
me.textbox1.value = worksheets("sheet1").range("A1").Text
End Sub

if not, you can do the formatting yourself.

Option Explicit
Private Sub UserForm_initialize()
Me.TextBox1.Value _
= Application.Text(Worksheets("sheet1").Range("A1"). Value, "# #/##")
End Sub

wrote:

Is there a way to make it so a userform textbox will only display
fractions ?

For Example:

If TextBox1 = A1 when the userform is activated and A1 has a value of
1.5 I want the textbox to show 1 1/2 . Any help on this would be
greatly appreciated.

Thanks


--

Dave Peterson


All times are GMT +1. The time now is 09:46 AM.

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