|
改了一下,原数据第一列从纯数据开始提取,和自动计算楚数据行数
Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
Dim i, uu, kk, rr
Dim pp
uu = Sheets(2).Cells(65536, 1).End(xlUp).Row
'ThisWorkbook.Sheets(2).Select
For kk = 1 To uu
pp = Sheets(2).Range("A" & kk)
If Not VBA.IsNumeric(pp) Then
kk = kk + 1
rr = kk
End If
Next
Sheets(2).Range(Sheets(2).Cells(rr + 1, 1), Sheets(2).Cells(uu, 2)).Copy
Sheets(1).Cells(2, 1).PasteSpecial Paste:=xlPasteValues
For i = 2 To Worksheets.Count
Sheets(i).Range(Sheets(i).Cells(rr + 1, 2), Sheets(i).Cells(uu, 2)).Copy
Sheets(1).Cells(2, i).PasteSpecial Paste:=xlPasteValues
Sheets(1).Cells(1, i) = Sheets(i).Name
Next
ThisWorkbook.Sheets(1).Select
Range("a1").Select
MsgBox "合并完成", 64, "提示"
CommandButton3.Enabled = False
Application.ScreenUpdating = True
End Sub |
|