|
- Sub test1()
- Dim ar, i As Integer, j As Integer, k As Integer
- Dim strName As String, Sht As Worksheet
- Application.ScreenUpdating = False
- On Error Resume Next
- ar = Worksheets("明细").Range("A1").CurrentRegion
- For j = 1 To UBound(ar, 2)
- k = 0
- strName = Split(Cells(1, j).Address, "$")(1)
- Set Sht = Worksheets(strName)
- If Err.Number <> 0 Then
- Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = strName
- Set Sht = ActiveSheet
- Err.Clear
- End If
- Sht.Cells.Delete
- For i = 1 To UBound(ar)
- If Len(ar(i, j)) Then
- k = k + 1
- If k = 1 Then
- Worksheets(ar(i, j)).Range("A1").CurrentRegion.Copy Sht.Range("A1")
- Else
- With Worksheets(ar(i, j)).Range("A1").CurrentRegion
- Intersect(.Offset(0), .Offset(4)).Copy Sht.Range("A65536").End(3)(2)
- End With
- End If
- End If
- Next
- Next
- Worksheets("明细").Activate
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|