|
- Sub lqxs()
- Dim Arr, i&, x$, y$, aa, j&, fso, myPath$, pa$, pa1$, nm1$
- Dim d, k, t, kk, tt, f, ii&, s$
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set fso = CreateObject("Scripting.FileSystemObject")
- Sheet1.Activate
- myPath = ThisWorkbook.Path & ""
- Arr = [a1].CurrentRegion
- For i = 2 To UBound(Arr)
- x = Arr(i, 3): y = ""
- aa = Split(Arr(i, 2))
- For j = 0 To UBound(aa) - 2
- y = y & aa(j) & " "
- Next
- If d.exists(x) = False Then Set d(x) = CreateObject("Scripting.Dictionary")
- d(x)(y) = d(x)(y) & Arr(i, 4) & ","
- Next
- k = d.keys: t = d.items
- For i = 0 To UBound(k)
- pa = myPath & k(i): Set f = Nothing
- If Not (fso.FolderExists(pa)) Then
- Set f = fso.CreateFolder(pa)
- End If
- kk = t(i).keys: tt = t(i).items
- For ii = 0 To UBound(kk)
- If Not f Is Nothing Then
- pa1 = f.Path & "" & kk(ii): s = ""
- Else
- pa1 = pa & "" & kk(ii): s = ""
- End If
- tt(ii) = Left(tt(ii), Len(tt(ii)) - 1)
- If InStr(tt(ii), ",") Then
- aa = Split(tt(ii), ",")
- For j = 0 To UBound(aa)
- s = s & aa(j) & vbCrLf
- Next
- Else
- s = tt(ii)
- End If
- nm1 = pa1 & " 共" & UBound(aa) + 1 & "单.txt"
- Open nm1 For Output As #1
- Print #1, s
- Close (1)
- Next
- Next
- MsgBox "OK"
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|