Word 2003

E

Enterprise Teacher

I have started a new job and been given an existing Word doc which has a
number of rows and columns. I want to use the info which has been put into
one of the columns but then use this info as a row in a new doc, i.e.,
instead of the info in the cells reading down the LHS of the page, they
become the heading row in a new doc. Can I do this easily or do I have to
laboriously cut and paste each cell? Thanks
 
G

Graham Mayor

What you ask is fairly simple to achieve with a macro. The following will
work with any simple table regardless of the number of columns/rows. -
http://www.gmayor.com/installing_macro.htm . Select the column you want to
copy at the prompt. A new document is created with a new table with as many
columns as there are rows, with the column content as the row header as
requested.

Dim oTable As Table
Dim oTargetTable As Table
Dim oRng As Range
Dim iCol As Integer
Dim oTarget As Document
Set oTable = Selection.Tables(1)
Set oTarget = Documents.Add
Set oTargetTable = oTarget.Tables.Add(oTarget.Range, _
1, oTable.Rows.Count)
iCol = InputBox("Copy which column? 1 to " & oTable.Columns.Count)
For i = 1 To oTable.Rows.Count
Set oRng = oTable.Cell(i, iCol).Range
oRng.End = oRng.End - 1
oTargetTable.Cell(1, i).Range.Text = oRng.Text
Next i


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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