|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim mypath$, myname$
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:e" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 4)) Then
- Set d(arr(i, 4)) = CreateObject("scripting.dictionary")
- End If
- d(arr(i, 4))(i) = Empty
- Next
- End With
- For Each aa In d.keys
- ss = Empty
- For Each bb In d(aa).keys
- ss = ss & vbLf & arr(bb, 1)
- Next
- Open ThisWorkbook.Path & "" & aa & ".txt" For Output As #1
- Print #1, Mid(ss, 2)
- Close #1
- Next
- End Sub
复制代码 |
|