Is there a way to turn rows into columns in Word?

F

felicitator72

Im trying to import a Word table into Excel but I want the rows in Word to be
columns in Excel. Is this possible?
 
S

Suzanne S. Barnhill

You have to do it in Excel. Paste into Excel. Then copy in Excel and use
Paste Special: Transpose. Or it may be you can use Paste Special when you
initially paste into Excel.
 
H

Helmut Weber

Hi Suzanne, hi Felicitator,

if it has to be,
just out of fun:

Sub RowColumnChange()
Dim r As Long ' row
Dim c As Long ' column
Dim st As String ' Temporary string
Dim s1 As String ' string from cell 1
Dim s2 As String ' string from cell 2
Dim t As Table
Set t = ActiveDocument.Tables(3)
With t
For r = 1 To t.Rows.Count - 1
For c = r To t.Columns.Count
s1 = t.Cell(r, c).Range.Text
s1 = left(s1, Len(s1) - 2)
s2 = t.Cell(c, r).Range.Text
s2 = left(s2, Len(s2) - 2)
st = s1
t.Cell(r, c).Range.Text = s2
t.Cell(c, r).Range.Text = st
Next
Next
End With
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
H

Helmut Weber

....
of course,
the sample would apply to the 3rd table in a doc
....

Use
Set t = selection.Tables(1)

for the first table in the selection

or just put the cursor in the table in question.


HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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