A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

The tables are turned! Well... not yet.



 
 
Thread Tools Display Modes
  #11  
Old October 27th, 2006, 03:10 AM posted to microsoft.public.word.tables
Tesla
external usenet poster
 
Posts: 8
Default The tables are turned! Well... not yet.

Thanks for reporting the problem with the macro.
Please see second posting, which addresses the problem by not using an
auxiliary table.

"macropod" wrote:

I am sorry that this forum danced around the issue and gave you
no good advice.


Really? The other solutions offered all do the job in various ways, at least
one of which met the OP's needs.

Your code needs more work. I tried it with a 5-column, 4-row table and
nothing was transposed. Plus, if the table is at the very top of the
document, the code crashes.

Cheers

--
macropod
[MVP - Microsoft Word]



  #12  
Old October 27th, 2006, 03:13 AM posted to microsoft.public.word.tables
Tesla
external usenet poster
 
Posts: 8
Default The tables are turned! Well... not yet.

Everyone thank macropod for alpha testing the macro, here is version 2, much
improved:

Option Explicit
Sub TransposeTableSelected()
Dim c As New Collection
Dim o
For Each o In Selection.Tables
c.Add o
Next
Dim t As Table
For Each t In c
TransposeTable t
Next
End Sub
Sub TransposeTable(t As Table)
If t Is Nothing Then
Exit Sub
End If
Dim original_rows As Integer
original_rows = t.Rows.Count

Dim original_cols As Integer
original_cols = t.Columns.Count

Dim diagonal_count As Integer
diagonal_count = IIf(original_rows original_cols, original_rows,
original_cols)

' increase size
Do While t.Rows.Count diagonal_count
t.Rows.Add
Loop
Do While t.Columns.Count diagonal_count
t.Columns.Add
Loop
' add a row to hold values as they are shuffled.
t.Rows.Add

Dim j As Integer
Dim k As Integer
For k = 1 To diagonal_count
For j = k + 1 To diagonal_count
Call TableCellSwap(t, k, j, j, k)
Next
Next

' decrease size
Do While t.Rows.Count original_cols
t.Rows(t.Rows.Count).Delete
Loop
Do While t.Columns.Count original_rows
t.Columns(t.Columns.Count).Delete
Loop
End Sub
Sub TableCellMove(sourceTable As Table, sourceRow As Integer, sourceCol As
Integer, destTable As Table, destRow As Integer, destCol As Integer)
sourceTable.Cell(sourceRow, sourceCol).Select
Selection.Cut

destTable.Cell(destRow, destCol).Select
Selection.Paste
End Sub
Sub TableCellSwap(sourceTable As Table, sourceRow As Integer, sourceCol As
Integer, destRow As Integer, destCol As Integer)
Call TableCellMove(sourceTable, destRow, destCol, sourceTable,
sourceTable.Rows.Count, 1)
Call TableCellMove(sourceTable, sourceRow, sourceCol, sourceTable,
destRow, destCol)
Call TableCellMove(sourceTable, sourceTable.Rows.Count, 1, sourceTable,
sourceRow, sourceCol)
End Sub


"Tesla" wrote:

Yes, there is. It involves a small macro that the vendor does not ship with
the product. I am sorry that this forum danced around the issue and gave you
no good advice.

This is a complete solution, which handles multiple tables selected, of any
size, even with embedded OLE objects in the cells, and keeps the original
formatting of the table. I worked Equations objects successfully in them.

Do not panic with the seemingly chaotic dance of tables and selections in
the document during processing, it all works nicely.

Here it is:


see version 2 above.
  #13  
Old October 27th, 2006, 03:19 AM posted to microsoft.public.word.tables
Tesla
external usenet poster
 
Posts: 8
Default The tables are turned! Well... not yet.

Your tone is not welcome. And you have not contributed to a solution.

This is a discussion about transposing tables in Word;
not matrices, not Excel documents.

99.9% of statistics are made up by the people that quote them.

"Pat Garard" wrote:

Hi Sweetheart,

Yes, there is. It involves a small macro that the vendor does not ship with ..

Thank you SO MUCH for a lesson in matrix transposition. Of course the
Vendor actually shipped the solution in Excel ...

99.9% of Word Users do not need matrices ...
99.9% of Excel Users MIGHT ....

I feel so ... enriched ...
--
Regards,
Pat Garard
Melbourne, Australia


  #14  
Old October 27th, 2006, 12:17 PM posted to microsoft.public.word.tables
macropod
external usenet poster
 
Posts: 1,231
Default The tables are turned! Well... not yet.

Still needs more work - bombs on tables with merged cells.

Cheers

--
macropod
[MVP - Microsoft Word]


"Tesla" wrote in message
...
Everyone thank macropod for alpha testing the macro, here is version 2,

much
improved:

Option Explicit
Sub TransposeTableSelected()
Dim c As New Collection
Dim o
For Each o In Selection.Tables
c.Add o
Next
Dim t As Table
For Each t In c
TransposeTable t
Next
End Sub
Sub TransposeTable(t As Table)
If t Is Nothing Then
Exit Sub
End If
Dim original_rows As Integer
original_rows = t.Rows.Count

Dim original_cols As Integer
original_cols = t.Columns.Count

Dim diagonal_count As Integer
diagonal_count = IIf(original_rows original_cols, original_rows,
original_cols)

' increase size
Do While t.Rows.Count diagonal_count
t.Rows.Add
Loop
Do While t.Columns.Count diagonal_count
t.Columns.Add
Loop
' add a row to hold values as they are shuffled.
t.Rows.Add

Dim j As Integer
Dim k As Integer
For k = 1 To diagonal_count
For j = k + 1 To diagonal_count
Call TableCellSwap(t, k, j, j, k)
Next
Next

' decrease size
Do While t.Rows.Count original_cols
t.Rows(t.Rows.Count).Delete
Loop
Do While t.Columns.Count original_rows
t.Columns(t.Columns.Count).Delete
Loop
End Sub
Sub TableCellMove(sourceTable As Table, sourceRow As Integer, sourceCol As
Integer, destTable As Table, destRow As Integer, destCol As Integer)
sourceTable.Cell(sourceRow, sourceCol).Select
Selection.Cut

destTable.Cell(destRow, destCol).Select
Selection.Paste
End Sub
Sub TableCellSwap(sourceTable As Table, sourceRow As Integer, sourceCol As
Integer, destRow As Integer, destCol As Integer)
Call TableCellMove(sourceTable, destRow, destCol, sourceTable,
sourceTable.Rows.Count, 1)
Call TableCellMove(sourceTable, sourceRow, sourceCol, sourceTable,
destRow, destCol)
Call TableCellMove(sourceTable, sourceTable.Rows.Count, 1,

sourceTable,
sourceRow, sourceCol)
End Sub


"Tesla" wrote:

Yes, there is. It involves a small macro that the vendor does not ship

with
the product. I am sorry that this forum danced around the issue and gave

you
no good advice.

This is a complete solution, which handles multiple tables selected, of

any
size, even with embedded OLE objects in the cells, and keeps the

original
formatting of the table. I worked Equations objects successfully in

them.

Do not panic with the seemingly chaotic dance of tables and selections

in
the document during processing, it all works nicely.

Here it is:


see version 2 above.



  #15  
Old October 28th, 2006, 04:50 PM posted to microsoft.public.word.tables
Tesla
external usenet poster
 
Posts: 8
Default The tables are turned! Well... not yet.

One more restriction to that approach: unfortunately that does not handle all
the things that can be in a cell, such as Objects (see MS Equation) or
captions, when one goes from Word to Excel.

The quest continues.

"Suzanne S. Barnhill" wrote:

Although "macropod" has given you the options within Word, there is a way to
transpose the rows and columns, but it will work only if the table is fairly
simple (no merged cells, not too much fancy formatting). Copy the table in
Word, then open Excel and use Paste Special: Transpose. This will swap the
rows and columns, and you can then copy/paste the text back into Word.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Cooz" wrote in message
...
Hi everyone,

Is there a way to turn a Word table so that its columns become rows and

its
rows become columns? If yes... how?

Thank you,
Cooz



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Relationships set up linronamy New Users 7 February 20th, 2006 11:45 PM
Criterion - How to Write Query for Multiple Tables jcinn Running & Setting Up Queries 1 February 8th, 2005 01:42 PM
Appending data from one table to multiple relational tables Stranger Running & Setting Up Queries 42 August 18th, 2004 02:55 AM
Mutliple Tables lookup? Westley Database Design 4 June 15th, 2004 01:07 AM
How do I design a database based on the information that will be stored? - Copy of Tables and hirearchies.zip (0/1) Jim Database Design 1 June 1st, 2004 01:44 PM


All times are GMT +1. The time now is 05:11 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.