separate two strings
Perhaps this will help some:
Sub test()
Dim lngTemp As Long
Dim sAuthor As String
Dim sTitle As String
strLiterature = Range("A1").Value
lngTemp = InStr(1, strLiterature, ":", vbTextCompare)
If lngTemp 0 Then
sAuthor = Trim$(Left$(strLiterature, lngTemp - 1))
sTitle = Trim$(Mid$(strLiterature, lngTemp + 1, Len(strLiterature)))
End If
End Sub
"Max Bialystock" wrote:
A cell contains an author's name and a book title separated by a colon.
Charles Dickens : Great Expectations
I need to get "Charles Dickens" into sAuthor
and "Great Expectations" into sTitle.
In this case there is always a space before and after the colon.
|