find Words between quotes

S

spoefi

Hi,

I need to find all the words between quotes in an .rtf file and mov
them to an excel -sheet.

Is there an easier way than by just searching for the first quote an
then checking each next character?

Does anybody have an idea?

Thanks,
spoef
 
J

Jerry W. Lewis

FIND() has an optional 3rd argument to specify the number of of the
occurance, so you can potentially determine the character position of
the first and second quote.

MID() pulls out a substring, so you could potentially extract the string
between quotes.

Given that substring, you could identify words by using FIND() to locate
spaces.

I say potentially, because you may run afoul of limits on the length of
strings.

Here is a VBA function to count the number of words.

Function WordCount(ByVal text, Optional ByVal delimiters)
If IsMissing(delimiters) Then
delimiters = ""
Else
If delimiters = "" Or delimiters = " " Then
delimiters = " "
Else
If InStr(delimiters, " ") = 0 And InStr(text, " ") > 0 Then
If InStr(text & delimiters, Chr(1)) > 0 Then
WordCount = [#VALUE!]: Exit Function
Else
text = Application.Substitute(text, " ", Chr(1))
End If
End If
Do While Len(delimiters) > 0
text = Application.Substitute(text, Left(delimiters,
1), " ")
delimiters = Mid(delimiters, 2)
Loop
End If
End If
text = Trim(text)
If Len(text) = 0 Then WordCount = 0: Exit Function
WordCount = 1
Do
pos = InStr(text, " ")
If pos > 0 Then
text = Mid(text, pos + 1)
text = LTrim(text)
WordCount = WordCount + 1
End If
Loop While pos > 0
End Function

Jerry
 
Top