在 Word 中转置表格

在 Word 中转置表格

有没有办法在后功能区 Microsoft Word(目前使用 2013 版)中转置(交换行和列)?

例如,在此表中,我希望顶部标题放在左侧(én、te 等),左侧标题(van、megy、jön)放在顶部(显然数据也会移动) 待转置表

我目前复制并粘贴到 Excel 中,再次复制并粘贴,但选择特殊粘贴选项:转置,然后复制回 word。但是有没有合适的方法可以本地执行此操作?

转置菜单

答案1

我认为使用 Excel 是唯一的方法。

答案2

尝试这个宏:

Sub transpose01()
'
' transpose01 Macro
'
'
' to transpose rows and columns in a table
Dim NumCols As Long, NumRows As Long, RowCounter As Long, ColCounter As Long
Dim CellText As String
NumCols = ActiveDocument.Tables(1).Columns.Count
NumRows = ActiveDocument.Tables(1).Rows.Count
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=NumCols, NumColumns:=NumRows
RowCounter = 0
While RowCounter < NumRows
ColCounter = 0
While ColCounter < NumCols
CellText = ActiveDocument.Tables(1).Cell(RowCounter + 1, ColCounter + 1).Range.Text
CellText = Left(CellText, Len(CellText) - 2)
ActiveDocument.Tables(2).Cell(ColCounter + 1, RowCounter + 1).Range.InsertBefore CellText
ColCounter = ColCounter + 1
Wend
RowCounter = RowCounter + 1
Wend '

End Sub

答案3

有这方面的经验吗: https://www.extendoffice.com/documents/word/1413-word-transpose-rows-and-columns-table.html 免费试用后可能会收取费用吗?

相关内容