Inserting columns in rows with text

M

malyjohn

Hello!
I have in Word a table with following rows:
....
John
180cm 65kg 20/17 ws
Mike
178cm 75kg 30/15 ns
198753 198765 123 qd
Kevin
no data
Tom
173cm 73kg 40/18 es
....
I would like to insert columns in some of rows to get something like
that

John
180cm | 65kg | 20/17 | ws
Mike
178cm | 75kg | 30/15 | ns
198753 | 198765 | 123 | qd
Kevin
no data
Tom
173cm | 73kg | 40/18 | es
....
My table counts more than thousand rows so this makes way "by hand"
useless.
Is there any way in VBA to check row by row of the table and if row
satisfies some conditions insert colums with given width?
Thank you in advance
John Maly
 
C

Cindy M -WordMVP-

I have in Word a table with following rows:
....
John
180cm 65kg 20/17 ws
Mike
178cm 75kg 30/15 ns
198753 198765 123 qd
Kevin
no data
Tom
173cm 73kg 40/18 es
....
I would like to insert columns in some of rows to get something like
that

John
180cm | 65kg | 20/17 | ws
Mike
178cm | 75kg | 30/15 | ns
198753 | 198765 | 123 | qd
Kevin
no data
Tom
173cm | 73kg | 40/18 | es
....
My table counts more than thousand rows so this makes way "by hand"
useless.
Is there any way in VBA to check row by row of the table and if row
satisfies some conditions insert colums with given width?
Yes... with reservations. It depends on whether the information in the
rows that need to be changed can be uniquely identified. In the sample
you give us, the rows you want to split have spaces between the "data
elements". Can you rely on the fact that
- only rows containing spaces should be split
- that the only spaces in these row are where the splits should be
made?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
M

malyjohn

I don't want to split rows where are names and where are "no data".
And other rows where the splits should be made have more spaces than
one.
Any idea how to make it?
John Maly
 
C

Cindy M -WordMVP-

I don't want to split rows where are names and where are "no data".
And other rows where the splits should be made have more spaces than
one.
Any idea how to make it?
Well, the logic to determine what is a name and what is not is not buit
into any programming language. You have to define how to recognize whether
something is a name. If you can't do that, then no, it can't be done. If
you can do that, then...

You have to be sure that data items are clearly identifiable; that the
same character, or sets of characters, ALWAYS can be found between data
items. If you can do that, then it probably can be done.

If either of the above can't be defined, then no, it can't be done. If you
want me to give you sample code, then you MUST clearly define how these
things are recognized. The people in these groups are just like you: we
work for a living, our time is precious, we can't spend a lot of it trying
this/trying that until we figure out what you really mean.

If there's a language barrier (I get the feeling English isn't your first
language?), try stating the case in French or German, or ask in a group
specific for your language.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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