text box percent field
is there a way to have a text box on a userform automatically be set up to
receive a percent number amount? a user would be typing in, say...40%. i would like if the text box could already have a percent sign and whatever they type in the text box would be followed by that percent sign. i tried, Userform.TextBox.Value = Userform.TextBox.Value & "%" but that just repeated itself until the character max was filled. TIA. |
text box percent field
Userform.TextBox.Value =
Application.Substitute(Userform.TextBox.Value,"%", "") & "%" -- Regards, Tom Ogilvy "Spencer Hutton" wrote in message ... is there a way to have a text box on a userform automatically be set up to receive a percent number amount? a user would be typing in, say...40%. i would like if the text box could already have a percent sign and whatever they type in the text box would be followed by that percent sign. i tried, Userform.TextBox.Value = Userform.TextBox.Value & "%" but that just repeated itself until the character max was filled. TIA. |
text box percent field
Spencer,
You could try this. Private Sub textbox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger ByVal Shift As Integer) 'tab key Application.ScreenUpdating = False If KeyCode = "9" Or KeyCode = "13" Then With UserForm1 .TextBox1.Text = .TextBox1.Text & " " & "%" End With End If End Sub When the user tabs off or press the enter key the % will be placed i the textbox. Charle -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 02:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com