View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal[_3_] Robert Crandal[_3_] is offline
external usenet poster
 
Posts: 161
Default Fast way to truncate string

Suppose I have the following string.

Dim s as String
s = "Always eat lots of fruits and vegetables every day."

I would like to be able to truncate this string as quickly
as possible, beginning from a word of my choosing, all
the way to the end of the string.

So, if I choose the word "and" as my target word, the
above string should be transformed into:

"Always eat lots of fruits "

Essentially, all text after the first occurence of "and"
was removed from the string.

I'm looking for solution that runs quickly. Thanks!

~Rob