![]() |
Formating to Percents in a UserForm
I have the following code. In cell AA1:AA4 there are
numbers. For instance the number in cell AA1 is .35. The code pulls the value from the specified cells and displays it in the cooresponding textbox. When the userform is loaded, the text boxes display the numbers in .XX format..... for example Textbox1 displays .35. I would like for the textboxes to show the numbers in percent format. For example I would like textbox1 to show 35% instead of .35. What is the code for this? Private Sub UserForm_Initialize() Me.TextBox1.Value = Worksheets(1).Range("AA1").Value Me.TextBox2.Value = Worksheets(1).Range("AA2").Value Me.TextBox3.Value = Worksheets(1).Range("AA3").Value Me.TextBox4.Value = Worksheets(1).Range("AA4").Value End Sub Thanks in advance to all who reply. Todd Huttenstine |
Formating to Percents in a UserForm
Private Sub UserForm_Initialize()
Me.TextBox1.Value = Format(Worksheets(1).Range("AA1").Value,"0%") Me.TextBox2.Value = Format(Worksheets(1).Range("AA2").Value,"0%") Me.TextBox3.Value = Format(Worksheets(1).Range("AA3").Value,"0%") Me.TextBox4.Value = Format(Worksheets(1).Range("AA4").Value,"0%") End Sub -- Regards, Tom Ogilvy Todd Huttenstine wrote in message ... I have the following code. In cell AA1:AA4 there are numbers. For instance the number in cell AA1 is .35. The code pulls the value from the specified cells and displays it in the cooresponding textbox. When the userform is loaded, the text boxes display the numbers in .XX format..... for example Textbox1 displays .35. I would like for the textboxes to show the numbers in percent format. For example I would like textbox1 to show 35% instead of .35. What is the code for this? Private Sub UserForm_Initialize() Me.TextBox1.Value = Worksheets(1).Range("AA1").Value Me.TextBox2.Value = Worksheets(1).Range("AA2").Value Me.TextBox3.Value = Worksheets(1).Range("AA3").Value Me.TextBox4.Value = Worksheets(1).Range("AA4").Value End Sub Thanks in advance to all who reply. Todd Huttenstine |
Formating to Percents in a UserForm
Thank you thats worked great!
-----Original Message----- Private Sub UserForm_Initialize() Me.TextBox1.Value = Format(Worksheets(1).Range ("AA1").Value,"0%") Me.TextBox2.Value = Format(Worksheets(1).Range ("AA2").Value,"0%") Me.TextBox3.Value = Format(Worksheets(1).Range ("AA3").Value,"0%") Me.TextBox4.Value = Format(Worksheets(1).Range ("AA4").Value,"0%") End Sub -- Regards, Tom Ogilvy Todd Huttenstine wrote in message ... I have the following code. In cell AA1:AA4 there are numbers. For instance the number in cell AA1 is .35. The code pulls the value from the specified cells and displays it in the cooresponding textbox. When the userform is loaded, the text boxes display the numbers in .XX format..... for example Textbox1 displays .35. I would like for the textboxes to show the numbers in percent format. For example I would like textbox1 to show 35% instead of .35. What is the code for this? Private Sub UserForm_Initialize() Me.TextBox1.Value = Worksheets(1).Range("AA1").Value Me.TextBox2.Value = Worksheets(1).Range("AA2").Value Me.TextBox3.Value = Worksheets(1).Range("AA3").Value Me.TextBox4.Value = Worksheets(1).Range("AA4").Value End Sub Thanks in advance to all who reply. Todd Huttenstine . |
All times are GMT +1. The time now is 07:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com