|
- Sub lqxs()
- Dim col%, Myr&, Arr, d, k, t, i&, j&, m&, aa
- Dim Sht As Worksheet
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set Sht1 = ActiveSheet
- For Each Sht In Sheets
- If Sht.Name <> Sht1.Name And Sht.Name <> "模板" Then Sht.Delete
- Next Sht
- col = 3
- On Error Resume Next
- Myr = [a65536].End(xlUp).Row
- Arr = Range("a5:d" & Myr)
- For i = 1 To UBound(Arr)
- d(Arr(i, col)) = d(Arr(i, col)) & i & ","
- Next
- k = d.keys: t = d.items
- For i = 0 To UBound(k)
- Sheet3.Copy after:=Sheets(Sheets.Count)
- ActiveSheet.Name = k(i): m = 4
- t(i) = Left(t(i), Len(t(i)) - 1)
- If InStr(t(i), ",") Then
- aa = Split(t(i), ",")
- For j = 0 To UBound(aa)
- m = m + 1
- Cells(m, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, aa(j), 0)
- Next
- Else
- m = m + 1
- Cells(m, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, t(i), 0)
- End If
- Next
- Sht1.Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|