CokeOrCrack
Board Regular
- Joined
- Dec 13, 2015
- Messages
- 81
- I have a Userform that contains a Textbox where an applicant enters their first name
- Some applicants use two names in their first name with no hyphen (e.g. "Rose Ann")
Question
- I want the textbox to kick out spaces prior and following the name
- I also want to remove double or more spaces in the middle
Notes
- I have removed all spaces in my Last Name textbox (due to last names containing hyphens rather than spaces)
- The code is as follows:
- Line two is unrelated to this thread
- I'm assuming the code will be more complex for the First Name textbox, or is it similar?
Thanks
OJ
- Some applicants use two names in their first name with no hyphen (e.g. "Rose Ann")
Question
- I want the textbox to kick out spaces prior and following the name
- I also want to remove double or more spaces in the middle
Notes
- I have removed all spaces in my Last Name textbox (due to last names containing hyphens rather than spaces)
- The code is as follows:
Code:
Private Sub tbLastName_Change()
tbLastName.Value = Application.WorksheetFunction.Proper(tbLastName.Value)
tbLastName.Text = Replace(tbLastName.Text, " ", "")
End Sub
- Line two is unrelated to this thread
- I'm assuming the code will be more complex for the First Name textbox, or is it similar?
Thanks
OJ