|
Option Explicit
Sub TEST2()
Dim ar, br, i&, k&, r&, strPath$, strFileName$, strTxt$
Application.ScreenUpdating = False
ar = Worksheets(1).[A1].CurrentRegion.Value
strPath = ThisWorkbook.Path & "\"
For i = 2 To UBound(ar)
strFileName = strPath & ar(i, 1) & ".txt"
br = Worksheets(ar(i, 1)).Range(ar(i, 2)).Value
strTxt = ""
For k = 1 To UBound(br)
If k = 1 Then
strTxt = Join(Application.Index(br, k), vbTab)
Else
strTxt = strTxt & vbCrLf & Join(Application.Index(br, k), vbTab)
End If
Next k
Open strFileName For Output As #1
Print #1, strTxt
Close #1
Next i
Application.ScreenUpdating = True
Beep
End Sub
|
|