Reputation:
For example, if I had:
Sub TestModule()
Dim test As String
test = "Machine Head"
End Sub
How would I extract the word Machine and assign it to a variable? I have tried using the Search and Left functions but have not had much success.
Cheers!
Upvotes: 10
Views: 23109
Reputation: 152505
Use Split():
Sub TestModule()
Dim test As String
dim frstWrd as string
test = "Machine Head"
frstWrd = split(test," ")(0)
Debug.Print frstWrd
End Sub
Upvotes: 18