Dear Experts,
I have about 400 text files and I want to put them underneath each other in an excel sheet. The columns are always from A to O but the amount of lines variates.
I have this macro but it always stops at VerzVar = Dir(Pfadname & "*.txt").
Furthermore, it is possible to embed the deleting of the first line of each text file first?
Thanks heaps!!
Stefan
(I use Ecxel 2010 on a Mac 10.6.8)
I have about 400 text files and I want to put them underneath each other in an excel sheet. The columns are always from A to O but the amount of lines variates.
I have this macro but it always stops at VerzVar = Dir(Pfadname & "*.txt").
Furthermore, it is possible to embed the deleting of the first line of each text file first?
Thanks heaps!!
Stefan
(I use Ecxel 2010 on a Mac 10.6.8)
Code:
Sub copy_text_files_in_one_sheet ()
Dim VerzVar As String
Dim Pfadname As String
Dim QuellMappe As Workbook
Pfadname = "Users/stefan/Desktop/Test"
VerzVar = Dir(Pfadname & "*.txt")
Do While VerzVar <> ""
' Abfrage ob aktuell geschleifte Datei eine Text-Datei ist
If Right(VerzVar, 4) = ".txt" Then
Set QuellMappe = Workbooks.Open(Filename:=VerzVar)
QuellMappe.Sheets(1).Copy Before:=ThisWorkbook.Sheets(1)
QuellMappe.Close savechanges:=False
End If
VerzVar = Dir
Loop
End Sub