looping through comma delimited text

D

DZ

Hi

I need to do something with a comma delimited block of text.

.....like
text , text, text, etc

Can someone help me write a loop to loop through each block of text between
commas?

Thanks alot for any help
 
D

Doug Robbins - Word MVP

What do you want to do with it? Better to tell us that and then we would be
in a better position to provide advice.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

StevenM

: << I need to do something with a comma delimited block of text.
Like: text , text, text, etc. Can someone help me write a loop to loop
through each block of text between commas? >>

Perhaps there is a better method, but you might try something like:

Sub FindTextBetweenCommas()
Dim oRange As Range
Set oRange = ActiveDocument.Range
' First we create text to find
oRange.Text = "abc, def, ghi, jkl, mno, pqr, stu, vwx, yz,"
Application.ScreenRefresh
' Now we find each word between commas
For Each oWord In oRange.Words
If InStr(1, oWord.Text, ",") = 0 _
And InStr(1, oWord.Text, vbCr) = 0 Then
oWord.Select
MsgBox oWord.Text
End If
Next oWord
End Sub

Steven Craig Miller
 

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

Top