|
- Sub 按钮2_Click()
- Dim wbDst As Workbook
- Dim lCol As Long
- Dim lShtNumber As Long
- On Error GoTo ErrorHandler
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set wbDst = GetObject(ThisWorkbook.Path & Application.PathSeparator & "工作簿2.xls")
- With Worksheets("sheet10")
- Debug.Print "sheet10"
- For lCol = 84 To 99 Step 3
- lShtNumber = lShtNumber + 1
- Debug.Print lCol, lShtNumber, lShtNumber + 12
- .Range(.Cells(3, lCol), .Cells(3, lCol).End(xlDown)).Copy
- With wbDst
- .Worksheets("sheet" & lShtNumber).Cells(Rows.Count, 2).End(xlUp).Offset(2).PasteSpecial Transpose:=True
- .Worksheets("sheet" & lShtNumber + 12).Cells(Rows.Count, 2).End(xlUp).Offset(2).PasteSpecial Transpose:=True
- End With
- Application.CutCopyMode = False
- Next
- End With
- lShtNumber = 7
- With Worksheets("sheet18")
- Debug.Print "sheet18"
- For lCol = 84 To 99 Step 3
- Debug.Print lCol, lShtNumber, lShtNumber + 6
- .Range(.Cells(3, lCol), .Cells(3, lCol).End(xlDown)).Copy
- With wbDst
- .Worksheets("sheet" & lShtNumber).Cells(Rows.Count, 2).End(xlUp).Offset(3).PasteSpecial Transpose:=True
- .Worksheets("sheet" & lShtNumber + 6).Cells(Rows.Count, 2).End(xlUp).Offset(3).PasteSpecial Transpose:=True
- End With
- lShtNumber = lShtNumber + 1
- Application.CutCopyMode = False
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox "复制完成"
- wbDst.Close True
- Exit Sub
- ErrorHandler:
- MsgBox Err.Number & vbCrLf & _
- Err.Description
- End Sub
复制代码 |
|