Importing from .txt

jamieknight989

New Member
Joined
Sep 6, 2011
Messages
1
Hi there,

I work in an office where a lot of the time we copy and paste data from.txt documents into a database -- for example we'll extract the data after certain terms such as:

Date: 'dd/mm/yyyy'
Term: 99 years from 31st September 2007

Now I'd like to know if it would be possible for us to automate much of this and extract all the relevant data from 1 text file to 1 row in a spreadsheet, then moving on to the next file and importing all of that into a new row. The .txt file isn't formatted in columns at all or tab or comma delimited so I know it would be quite complicated - any help or advice on where to go to learn how to write the coding for such a process would be much appreciated

Cheers
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Does not work for 100%.:confused:
After recording the macro and running it again, instead of importing the specified file, a window is opened with the file already preselected.
I still need to press "import" for excel to actually import the data.
 
Upvote 0
Hi,

Code below recorded

Code:
Sheets("Import Data").Select
    Range("A1").Select
    With Selection.QueryTable
        .Connection = _
        "TEXT;D:\Documenten\Project Files\03 - Tools\P07292T - Maintenance ATP Mammo v5\Final Acceptance Certificate EN.txt"
        .TextFilePlatform = 28591
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileOtherDelimiter = ";"
        .TextFileColumnDataTypes = Array(1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top