第二列 第四列
1111 4444
2222 5555
3333 6666
如上,怎么用程序将表格中第二列的内容和第四列的内容交换,变成如下的: 第四列         第二列
4444        1111
5555        2222
6666        3333
感恩~~~

解决方案 »

  1.   

        呵呵,我遇到一个类似的问题,正准备来csdn求较呢。就先看到你的问题,先帮你解决下[code]
    Sub SwapCol(col1 As Integer, col2 As Integer)
        Dim s As String
        Dim row As row
        For Each row In ActiveDocument.Tables(1).Rows
            s = row.Cells(col1).Range.Text
            row.Cells(col1).Range.Text = row.Cells(col2).Range.Text
            row.Cells(col2).Range.Text = s
        Next
        
    End Sub
    [/code]
      

  2.   

       奇怪了,我不是贴上代码了吗?怎么没有看到我的函数呢
    Sub SwapCol(col1 As Integer, col2 As Integer)
        Dim s As String
        Dim row As row
        For Each row In ActiveDocument.Tables(1).Rows
            s = row.Cells(col1).Range.Text
            row.Cells(col1).Range.Text = row.Cells(col2).Range.Text
            row.Cells(col2).Range.Text = s
        Next
        
    End Sub