|
Sub Macro1()
Dim x%, x1%, x2%, m$
x1 = 3
m = Sheets("总表").Cells(3, 1)
For x = 4 To 39
If m <> Sheets("总表").Cells(x, 1) Or x = 39 Then
Sheets.Add
With ActiveSheet
.Name = m
.Range(.Cells(3, 1), .Cells(x2 + 3, 5)) = Sheets("总表").Range(Sheets("总表").Cells(x1, 1), Sheets("总表").Cells(x + 2, 5)).Value
End With
Sheets("总表").Range("A1:E2").Copy
Sheets(m).Paste
Sheets("总表").Range("A40:E42").Copy
Sheets(m).Range("A" & x2 + 4).Select
ActiveSheet.Paste
x1 = x
m = Sheets("总表").Cells(x, 1)
x2 = 0
Else
x2 = x2 + 1
End If
Next
End Sub |
|