|
本帖最后由 lijian8003 于 2015-12-14 13:54 编辑
Sub 导入()
For x = 1 To 42
Sheets("x").Select
Application.DisplayAlerts = False
Dim s() As String
Open "d:\分解\软件\Right("000" & x, 4)\lishi\" & "1.txt" For Input As #1
s = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf)
Close #1
[A2].Resize(UBound(s) + 1, 1) = WorksheetFunction.Transpose(s)
[A:A].TextToColumns [A2]
Application.DisplayAlerts = True
Next
End Sub
加红部分的文件夹0001 0002 ... 0042,如何表示?
本帖最后由 zjdh 于 2015-12-14 08:27 编辑
Open "d:\分解\软件\Right("000" & x, 4)\lishi\" & "1.txt" For Input As #1
改成
Open "d:\分解\软件\" & Format( x, "0000") & "\lishi\1.txt" For Input As #1
|
|