|
- Sub test()
- Dim brr()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each sht In Sheets
- If sht.Name <> "总表" Then sht.Delete
- Next sht
- last_row = Cells(Rows.Count, 1).End(xlUp).Row
- last_column = Cells(last_row, 1).End(xlToRight).Column
- arr = Range([a1], Cells(last_row, last_column))
- For row1 = 1 To UBound(arr)
- If InStr(Cells(row1, 1).Value, "库存现金-现金先令") Then
- k = k + 1
- ReDim Preserve brr(1 To 3, 1 To k)
- brr(1, k) = Cells(row1, 1).Value
- brr(2, k) = "A" & row1
- ElseIf InStr(Cells(row1, 5).Value, "本年累计") Then
- brr(3, k) = "I" & row1
- End If
- Next row1
- For c = 1 To UBound(brr, 2)
- Sheets.Add(after:=Sheets(Sheets.Count)).Name = brr(1, c)
- Sheets("总表").Range(brr(2, c), brr(3, c)).Copy Sheets(brr(1, c)).Range("a1")
- Columns.AutoFit
- Next c
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|