|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub TEST()
Dim arr, brr(), i&, R&, dic As Object, vKey
Set dic = CreateObject("Scripting.Dictionary")
arr = [a1].CurrentRegion
For i = 2 To UBound(arr)
dic(arr(i, 2)) = ThisWorkbook.Path & "\" & arr(i, 2) & ".txt"
Next i
For Each vKey In dic.keys
Erase brr: R = 0
For i = 2 To UBound(arr)
If arr(i, 2) = vKey Then
R = R + 1
ReDim Preserve brr(1 To R)
brr(R) = arr(i, 1)
End If
Next i
Open dic(vKey) For Output As #1
Print #1, Join(brr, vbCrLf)
Close #1
Next
Set dic = Nothing
End Sub
|
|