第二列 第四列
1111 4444
2222 5555
3333 6666
如上,怎么用程序将表格中第二列的内容和第四列的内容交换,变成如下的: 第四列 第二列
4444 1111
5555 2222
6666 3333
感恩~~~
1111 4444
2222 5555
3333 6666
如上,怎么用程序将表格中第二列的内容和第四列的内容交换,变成如下的: 第四列 第二列
4444 1111
5555 2222
6666 3333
感恩~~~
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]
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