|
- Sub Macro1()
- Dim mypath$, wb$, s&
- Dim arr()
- mypath = ThisWorkbook.Path & ""
- wb = Dir(mypath & "*.txt")
- Do While wb <> ""
- s = s + 1
- If s > 246 Then GoTo aa '第K列到第IV列共246列
- Open mypath & wb For Input As #1
- w = Split(StrConv(InputB(LOF(1), #1), vbUnicode), vbCrLf)
- Close #1
- ReDim Preserve arr(1 To 1005, 1 To s) '[K1:IV1005]共1005行
- n = 0
- For i = 0 To UBound(w)
- If Len(w(i)) > 0 Then
- n = n + 1
- If n > 1005 Then Exit For
- arr(n, s) = w(i)
- End If
- Next
- Erase w
- wb = Dir
- Loop
- aa: If s > 0 Then [k1].Resize(1005, s) = arr
- End Sub
复制代码 |
|