Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2008

Tip: Looking for answers? Try searching our database.

looping through comma delimited text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DZ - 24 May 2008 05:04 GMT
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
Doug Robbins - Word MVP - 24 May 2008 09:33 GMT
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.

Signature

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

> Hi
>
[quoted text clipped - 8 lines]
>
> Thanks alot for any help
StevenM - 24 May 2008 19:29 GMT
"DZ" wrote: <<  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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.