I'd like a VBA code to grab the characters of a string until it gets to the first space character?
example
"Down in the valley"
will return "Down"
TIA
Stephen
I'd like a VBA code to grab the characters of a string until it gets to the first space character?
example
"Down in the valley"
will return "Down"
TIA
Stephen
Left(yourTextField,Instr(yourTextField," ") )
or as a function
and a test routineCode:Function LeftOfSpace(txtIn As String) As String LeftOfSpace = Left(txtIn, InStr(txtIn, " ")) End Function
downCode:Sub sep10() Dim a As String: a = "down in the valley" Debug.Print LeftOfSpace(a) End Sub
perfect - thank you
Stephen
another way is
split(yourTextField," ") (0)
but will only work in VBA, not in a query
shouldn't this be moved out of Knowledge Base / Code Repository?