|
- Sub tt()
- Dim ar, sh, i%, j%, head, dic, r, s, k
- Set dic = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- With Sheets("发货单维护")
- ar = .UsedRange
- Set head = .Range("a1:al5")
- For i = 6 To UBound(ar)
- If ar(i, 1) <> "" And Not dic.exists(ar(i, 1)) Then
- dic(ar(i, 1)) = ""
- Set sh = Sheets.Add
- sh.Name = ar(i, 1)
- head.Copy [a1].Resize(5, 38)
- r = [a104800].End(xlUp).Row + 1
- For j = 1 To UBound(ar, 2)
- If Not WorksheetFunction.IsNA(ar(i, j)) Then
- If ar(i, j) <> "" Then Sheets(ar(i, 1)).Cells(r, j) = ar(i, j)
- End If
- Next j
- ElseIf dic.exists(ar(i, 1)) Then
- Sheets(ar(i, 1)).Activate
- r = [a104800].End(xlUp).Row + 1
- For j = 1 To UBound(ar, 2)
- If Not WorksheetFunction.IsNA(ar(i, j)) Then
- If ar(i, j) <> "" Then Sheets(ar(i, 1)).Cells(r, j) = ar(i, j)
- End If
- Next j
- End If
- Next i
- For Each k In Sheets
- If k.Index < 9 Then
- Sheets(k.Name).Activate
- m = [a1048000].End(xlUp).Row - 5
- For i = 38 To 5 Step -1
- Set s = Cells(6, i).Resize(m, 1)
- If WorksheetFunction.Sum(s) = 0 Then
- Columns(i).Delete
- End If
- Next i
- End If
- Next k
- Set s = Nothing
- End With
- Set head = Nothing
- Set dic = Nothing
- Set s = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|