dashes in text string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top