dashes in text string

K

Kirk P.

Any good way to distinguish each "chunk" of text between the dashes? I would
like to take this text string and break it into 5 columns.

Care24 Svcs - Direct - Direct Health Plans - EWD USS - Medica
 
P

pietlinden

Kirk said:
Any good way to distinguish each "chunk" of text between the dashes? I would
like to take this text string and break it into 5 columns.

Care24 Svcs - Direct - Direct Health Plans - EWD USS - Medica

You either have to use text manipulation functions like MID, LEFT,
INSTR, RIGHT or you can do it something like this and then loop through
the array returned and write each to a field in your table.

Public Function SplitData(ByVal strData As String, ByVal strDelim As
String)
Dim varData As Variant 'place to put the broken out string
Dim intSubscript As Integer

varData = Split(strData, strDelim)
For intSubscript = LBound(varData) To UBound(varData)
Debug.Print Trim(varData(intSubscript))
Next intSubscript


End Function
 
J

Jerry Whittle

If you would happen to be importing this string as part of a text file, you
could go to the advanced options and make - the field seperator.
 
Top