合并两个页签,不包括表头

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/poinsettia/article/details/50700605

功能:新建一个页签并用把其他页签的内容合并过来

Sub Macro4()

'
' Macro3 Macro
    Dim Source_Sheet1  As String
    Dim Source_MinRow1 As Long
    Dim Source_MinCol1 As Long
    Dim Source_MaxRow As Long
    Dim Source_MaxCol As Long
    Dim Source_Sheet2  As String
    Dim Source_MinRow2 As Long
    Dim Source_MinCol2 As Long
    
    
    Dim Des_Sheet  As String
    
    '新建页签
    Worksheets.Add after:=Worksheets(Worksheets.Count)
    ActiveSheet.Name = "V1R11C10SPC100相对V1R11C00SPC100"
    
    '配置
    Des_Sheet = "V1R11C10SPC100相对V1R11C00SPC100"
    Source_Sheet1 = "Sheet1"
    Source_MinRow1 = 1
    Source_MinCol1 = 1
    Source_Sheet2 = "Sheet2"
    Source_MinRow2 = 4
    Source_MinCol2 = 1
    
    Source_MaxRow = Worksheets(Source_Sheet1).Cells(65535, 1).End(xlUp).Row
    Source_MaxCol = Worksheets(Source_Sheet1).Cells(1, 255).End(xlToLeft).Column
    Source_MaxRowTemp = Source_MaxRow
    
    Worksheets(Source_Sheet1).Select
    Range(Cells(Source_MinRow1, Source_MinCol1), Cells(Source_MaxRow, Source_MaxCol)).Select
    Selection.Copy
    Worksheets(Des_Sheet).Select
    Range("A1").Select
    ActiveSheet.Paste
    
    
    
    Source_MaxRow = Worksheets(Source_Sheet2).Cells(65535, 1).End(xlUp).Row
    Source_MaxCol = Worksheets(Source_Sheet2).Cells(1, 255).End(xlToLeft).Column
    
    Worksheets(Source_Sheet2).Select
    Range(Cells(Source_MinRow2, Source_MinCol2), Cells(Source_MaxRow, Source_MaxCol)).Select
    Selection.Copy
    Worksheets(Des_Sheet).Select
    Cells(Source_MaxRowTemp + 1, 1).Select
    ActiveSheet.Paste
    
    MsgBox "合并完成"
End Sub

猜你喜欢

转载自blog.csdn.net/poinsettia/article/details/50700605