+ Reply to Thread
Results 1 to 3 of 3

Importing data from text file

  1. #1
    Registered User
    Join Date
    03-08-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    16

    Importing data from text file

    Ive tried searching and using different methods and cannot figure this out. About 2-3 times a week I have about 25-100 different text files that I periodically need to import data from to my spreadsheet. The name of the text file will change each day but I am able to paste the titles in row 1 on my spreadsheet. Also, all of the text files are saved to their own folder each time and are not comingled with any other text files if that makes it easier.

    Ive attached a spreadsheet with the layout I am using and a sample the text file I am importing data from.

    Thanks in advance for any help.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Importing data from text file

    So is your ask here, to import the data from each text file regardless of folder/location into your spreadsheet?
    If so, do you already have the looping logic to handle looking for each file?

    If all you want to do is merely copy/import the data from the text file into your sheet, this is one method you can try
    , inside your loop call the logic below for each file you process.

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    According to the attachment to import a column the classic method VBA demonstration as a beginner starter :

    PHP Code: 
    Sub Demo1()
            
    Application.GetOpenFilename("Text Files,*.txt")
            If 
    False Then Exit Sub
        With 
    [A1].CurrentRegion.Columns
            W 
    = .Item(1).Value2
            W
    (11) = Split(V"\"):  W(1, 1) = W(1, 1)(UBound(W(1, 1)))
            F% = FreeFile
            Open V For Input As #F
            Line Input #F, W(2, 1):  Line Input #F, W(2, 1)
        For R& = 2 To UBound(W)
            Line Input #F, W(R, 1)
            W(R, 1) = Split(W(R, 1), vbTab)(3)
        Next
            Close #F
            With .Item(Cells(2, Columns.Count).End(xlToLeft).Column + 1):  .Value2 = W:  .AutoFit:  End With
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with importing data from text file
    By Frederik1234567 in forum Excel General
    Replies: 3
    Last Post: 12-21-2014, 03:34 PM
  2. [SOLVED] importing data from text file
    By askhari139 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2013, 01:36 PM
  3. Importing a data from a text file - user-defined file
    By DaveSev in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2013, 07:02 PM
  4. Data importing from Text file to Excel
    By yogeshkk2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2012, 04:38 AM
  5. Importing specific data from a Text file
    By cspellman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2007, 03:42 PM
  6. Importing data from a text file
    By jbaranski in forum Excel General
    Replies: 3
    Last Post: 08-01-2006, 10:10 AM
  7. Importing data from text file
    By tushar_johri in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2006, 05:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1