Hey guys,
I'm kinda new to VBA but i need to implement a search in a text box. I have a form containing a text box in which the user inputs data in the following way:
"owner of the account * NAME (other data)"
"owner of the account * NAME (other data)"
..
(multiple lines - up to 15)
I created a text box to extract the Name from the text with the following code:
When i run the form my excel crashes. Any idea on what i did wrong?
P.S. A similar post is here - i modified the code a bit: http://www.excelforum.com/excel-programming/674258-combo-list.html#post2052687
I'm kinda new to VBA but i need to implement a search in a text box. I have a form containing a text box in which the user inputs data in the following way:
"owner of the account * NAME (other data)"
"owner of the account * NAME (other data)"
..
(multiple lines - up to 15)
I created a text box to extract the Name from the text with the following code:
Code:
Private Sub ButChange_Click()
Dim Text As String
Dim Line As String
Dim Ntemp As String
Dim Name As String
'Init
Ntemp = ""
Name = ""
Line = ""
'temporary text to be parsed
Text = Chr(13) & TboxII.Text & Chr(13)
'while not temp text is empty
While InStr(Text, Chr(13)) <> 0
'take first line of text
Line = Left(Text, InStr(Text, Chr(13)) - 1)
'selecting the name
If InStr(Line, "You still have to kill") Then
Ntemp = Trim(Right(Line, Len(Line) - InStr(Line, "*")))
Name = Trim(Left(Ntemp, Len(Ntemp) - InStr(Ntemp, "(")))
ActiveCell.Value = Name
Cells(ActiveCell.Row + 1, ActiveCell.Column).Select
End If
Wend
P.S. A similar post is here - i modified the code a bit: http://www.excelforum.com/excel-programming/674258-combo-list.html#post2052687