View Full Version : [SLEEPER:] Combine multiple txt files
imranpaddy
11-03-2019, 01:59 AM
hi team
help required
need a macro to combine multiple txt files into one single excel worksheet along with (.txt) file name in column A
Please help. thank is advance.
TSV?
Option Explicit
Sub test()
Dim p As String
Dim fn As String
Dim r As Range
p = CreateObject("wscript.shell").specialfolders("desktop") & "\test\"
fn = Dir(p & "*.txt")
Do While fn <> ""
Set r = Cells(Rows.Count, 2).End(xlUp).Offset(1)
r.Offset(, -1).Value = fn
With ActiveSheet.QueryTables.Add("TEXT;" & p & fn, r)
.TextFileParseType = xlDelimited
.TextFileTabDelimiter = True
.Refresh False
.Delete
End With
fn = Dir
Loop
End Sub
マナ
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.