Vba to read column of text

B

Ben

Hi,

Is there a way using vba that can copy a particular column of the text that
i want and put into the column of the new file.

For example:
Existing colum

Name Age
Lee 23
tan 34
rich 34


Copy the column of the name and paste it into new file of a new column as
below:

Name
lee
tan
rich


please advise.

thanks.

regards,
ben
 
D

Dave Lett

Hi Ben,

You could use something as simple as the following:


ActiveDocument.Tables(1).Columns(1).Select
Selection.Copy

Documents.Add
Selection.Paste


Just be sure that it's really the first table of the document and first
column of the table that you want to copy.

HTH,
Dave
 
D

Dave Lett

Hi Ben,

Without knowing much about your text file, I'm going to say NO because the
text file won't have a table. However, if the text file is tab-delimited, as
in the following:

Name<tab>Age
Lee<tab>23
tan<tab>34
rich<tab>34

Then you can open the text file in Word, convert the appropriate material to
a table and then use the previous routine.

HTH,
Dave
 

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