View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default EXTRACTING SUBSTRINGS !!

Will you always have enough text to fill B, C, D, E and Leftover? Assuming
you will, use the optional 3rd argument for the Split function to control
the number of substrings being formed. For example...

Dim A As String
Dim brkout() As String
Dim B As String, C As String, D As String, E As String, Leftover As String

A = "This..Is..A..Long..Example..Test..String"

brkout= Split(A, "..", 5)
B = brkout(0)
C = brkout(1)
D = brkout(2)
E = brkout(3)
Leftover = brkout(4)

--
Rick (MVP - Excel)


"jay dean" wrote in message
...

Hello -

Dim A as string
Dim brkout() as string
Dim B as string, C as string, D as string, E as string, Leftover as
string

A contains text. I am trying to store the first 4 substrings of A in B,
C, D, and E. Then I want whatever else is left to be stored in Leftover.
The delimiter for the substrings is ".."

I have been able to use the SPLIT() function to store the first 4
strings using brkout=split(A,"..")
then B=brkout(1):C=brkout(2):D=brkout(3):E =brkout(4)

How do I store the remaining text left in brkout() (apart from B,C,D and
E) in Leftover?

Any help would be appreciated.

Jay


*** Sent via Developersdex http://www.developersdex.com ***