reafidy,
VB:strValue = "cars - buses" TextBox1 = split(strValue," - ")(0) TextBox2 = split(strValue," - ")(1)
Hi Everyone.
I have a cell containing a hyphen with data like cars - buses.
I have a userform set up with 2 text boxes. What I would like to do is when loading the userform put the information from the cell before the hyphen in one textbox and the information after the hyhen in another text box. ie one textbox would have cars the other textbox would have buses.
Anyhelp much appreciated.
reafidy,
VB:strValue = "cars - buses" TextBox1 = split(strValue," - ")(0) TextBox2 = split(strValue," - ")(1)
Regards,
Barry
My Favorite New Thing:
Dynamic Named Ranges
The alternative for
"Press Any Key To Continue."
and we all have one we'd like to use it on
![]()
iwrk4dedpr got there before me; and much more elegantly!
You might also consider using Trim() to trim any leading or trailing spaces. Also, although VBA allows you to write "TextBox1 = xxx", it is technically correct to write "TextBox1.Value = xxx"
VB:Option Explicit Private Sub UserForm_Activate() Dim StrValue As String StrValue = " cars - buses " TextBox1.Value = Trim(Split(StrValue, " - ")(0)) TextBox2.Value = Trim(Split(StrValue, " - ")(1)) End Sub
Last edited by Arthur494; January 10th, 2007 at 07:22.
Perfect, big thanks to you.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks