-1

I am trying to load in multiple txt files into my excel sheet using a sub function as shown below. However, the data is tab delimited - how do I get the data to be imported with this? " " doesn't seem to work.

Many thanks in advance!

Sub InsrtInfo()

Dim strFileToOpen As String

strFileToOpen = Application.GetOpenFilename(Title:="Please choose A", FileFilter:="Text Files (*.txt),*.txt,")
    copyDataFromTXTFileToSheet strFileToOpen, " ", "A"
strFileToOpen = Application.GetOpenFilename(Title:="Please choose B", FileFilter:="Text Files (*.txt),*.txt,")
    copyDataFromTXTFileToSheet strFileToOpen, " ", "B"
strFileToOpen = Application.GetOpenFilename(Title:="C", FileFilter:="Text Files (*.txt),*.txt,")
    copyDataFromTXTFileToSheet strFileToOpen, " ", "C"
strFileToOpen = Application.GetOpenFilename(Title:="D", FileFilter:="Text Files (*.txt),*.txt,")
    copyDataFromTXTFileToSheet strFileToOpen, " ", "D"
strFileToOpen = Application.GetOpenFilename(Title:="E", FileFilter:="Text Files (*.txt),*.txt,")
    copyDataFromTXTFileToSheet strFileToOpen, " ", "E"


End Sub
Rajan Sharma
  • 2,211
  • 3
  • 21
  • 33

1 Answers1

0

There is a great answer written by Siddharth Rout in the thread I linked below.

I used the Query Tables method to import over 3000 tab-delimited text files into 7 separate workbooks and it worked great, however you will find other ways to import text files in that thread too.

VBA Importing text file into Excel Sheet

Good luck!

Danny Papadopulos
  • 467
  • 1
  • 5
  • 14
  • Hi Danny, thanks this is a great thread! I'd like to see if the method above can be added to the list of ways :) – user2819098 Aug 13 '19 at 14:29