|
回复 4楼 wangzhongtu 的帖子
请测试:
Sub Macro1()
Dim arr, brr(1 To 3), crr(1 To 3)
arr = Range("B3:G3")
brr(1) = arr(1, 1)
brr(1 + 1) = arr(1, 2)
brr(1 + 2) = arr(1, 6)
crr(1) = arr(1, 3)
crr(1 + 1) = arr(1, 4)
crr(1 + 2) = arr(1, 5)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Workbooks.Open(ThisWorkbook.Path & "\工作簿2.xls")
With .Sheets("表2-1")
.Cells(2, 3).Resize(3) = WorksheetFunction.Transpose(brr)
.Cells(2, 6).Resize(3) = WorksheetFunction.Transpose(crr)
End With
.Close True
End With
Application.ScreenUpdating = True
MsgBox "完毕"
End Sub
Sub Macro2()
Dim arr, brr(1 To 3), crr(1 To 3)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With GetObject(ThisWorkbook.Path & "\工作簿1.xls")
With .Sheets("表1-1")
arr = .Range("B3:G3")
brr(1) = arr(1, 1)
brr(1 + 1) = arr(1, 2)
brr(1 + 2) = arr(1, 6)
crr(1) = arr(1, 3)
crr(1 + 1) = arr(1, 4)
crr(1 + 2) = arr(1, 5)
End With
.Close False
End With
With Workbooks.Open(ThisWorkbook.Path & "\工作簿2.xls")
With .Sheets("表2-1")
.Cells(2, 3).Resize(3) = WorksheetFunction.Transpose(brr)
.Cells(2, 6).Resize(3) = WorksheetFunction.Transpose(crr)
End With
.Close True
End With
Application.ScreenUpdating = True
MsgBox "完毕"
End Sub |
|