Flow many lines into 1 very long line

D

drbobsled

I need to flow several lines together.

The data looks like this, only there are over 1000 lines.
100010206116W502
100010207506W500
100010503204W502


it needs to become
IN(100010206116W502,100010207506W500,100010503204W502)

to be pasted into a "canned" SQL filter in another program.

How can I tell VBA to go to the line end and add a comma, remove the return,
repeat to the end of the file and add the ")"?

Thank-you.
 
D

Doug Robbins

Assuming that there is a carriage return at the end of every line, use
Edit>Replace to replace ^p with a comma. Probably easiest then just to move
to the end of the line and insert the )

Fairly easy to automate if you want to, but hardly worth the effort.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
J

Jezebel

You haven't said where these lines are coming from, but assuming a text
file, you could use something like

Dim pFileNum as long
Dim pOutput as string

pFileNum = freefile
Open SourcFile for input as pFileNum
pOutput = "IN(" & replace(input(LOF(pFileNum), pFileNum), vbCr, ",") & ")"
Close pFileNum

Depending on what created the source, you might need to use vbCrLf in place
of vbCr.
 

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