You need to define 'word' in this context. If you mean a string beginning
with a capital letter, or comprising letters only, then Find and Replace
will do it, as will VBA. Here's another VBA --
Dim pWords() as string
pWords = Split(Range.Text, " ")
For i = 0 to ubound(pWords)
if pWords(i) like "[a-zA-Z]{1,}" then
pStartWord = i
exit for
end if
Next
Output = pWords(pStartWord)
For i = pStartWord + 1 to ubound(pWords)
Output = Output & " " & pWords(i)
Next
> Hello Chuck from Steved
>
[quoted text clipped - 174 lines]
>>>
>>.
Steved - 03 Feb 2005 22:41 GMT
Hello Jezebel from Steved
Jezebel as you would have quessed and that is that
I am not very good at explaning my issue here.
I would like to thankyou for your patience.
Cheers.
>-----Original Message-----
>You need to define 'word' in this context. If you mean a string beginning
[quoted text clipped - 195 lines]
>
>.
Chuck - 04 Feb 2005 12:03 GMT
Hi Jezebel
When I tested your code it worked fine except that it kept returning the
original string as Output. However if I amended the line containing the Like
operator it worked fine, eg:
Replace: if pWords(i) like "[a-zA-Z]{1,}" then
with: if pWords(i) like "[a-zA-Z]*" then
Unless I'm missing something?
I also took the liberty of making a Function from your code:
Function StripStringToWords(sString As String)
Dim pWords() As String
Dim Output As String
Dim i As Long
Dim pStartWord As Long
pWords = Split(sString, " ")
For i = 0 To UBound(pWords)
If pWords(i) Like "[a-zA-Z]*" Then
pStartWord = i
Exit For
End If
Next
Output = pWords(pStartWord)
For i = pStartWord + 1 To UBound(pWords)
Output = Output & " " & pWords(i)
Next
StripStringToWords = Output
End Function
Chuck
> You need to define 'word' in this context. If you mean a string beginning
> with a capital letter, or comprising letters only, then Find and Replace
[quoted text clipped - 192 lines]
> >>>
> >>.