How To Import Multiple Text Files Based On Date

Feb 14, 2014

I am trying to an excel macro that will automatically import data from specific files. The basic information is this:

1. There is a MySQL script that runs every day and creates tab-delimited text file named as the date.Example:

OutputDIR
02-14-2014.txt
02-15-2014.txt
02-16-2014.txt

2. I need grab data from each of the files for a rolling 30 day period from the date specified in the sheet. The data needs to go onto the same sheet in Excel.Example: B2 on the "Settings" worksheet says 02-14-2014. So take data from 02-14-2014 minus 30 days (01-15-2014.txt) all the way up to today and consolidate it onto an existing worksheet called "Data."

3. If the date in cell B2 is changed, overwrite the data that was already retrieved and replace it with the new import from the new date.Example: B2 is changed to 01-31-2014. Now take data from 01-31-2014 minus 30 days and overwrite what was already imported in worksheet "Data."

View 5 Replies


ADVERTISEMENT

Import Multiple Text Files Based On Parameters

Mar 11, 2008

I get about 10 text files at the beginning of each month that I need to import into Excel. The file layout does change slightly from month to month so I have an Excel spreadsheet with the layout as the first worksheet. Each text file is in fixed layout form rather than delimited. The structure of that page is that the name of the first text file is in cell A1. The cumulative field widths are below that and the data formats are next to the field widths (in the adjacent column “B”). T=Text, G=General, D= Date with 3 flavors of Date: YMD, DMY and MDY. For the second text file, it repeats the structure in columns “C” and “D”, the third text file in columns “E” and “F” etc. What I would like is for the macro to open the first text file (based on the name in cell A1) and import it into a new worksheet (same file) using the cumulative field widths in A2 through A8 and the formats from B2 through B8, then import the next text file to a new worksheet (same file) using the cumulative field widths in C2 through C8 and the formats from D2 through D8 and keep going until all the files have been imported. The sheet names should be the same as the file that is imported (the “.txt” part of the file name isn’t important). I’ve attached a copy of the Excel spreadsheet that has the file names, field widths (cumulative) and field formats and a 2 row sample of the text file for the first import.

View 6 Replies View Related

Import Multiple Text Files & Copy Each Import

Jan 29, 2008

I'm attempting to import around 200 (and growing!) separate text files into Excel. I am using the formula below to import the text file and then using a separate macro to select the information I need, copy it into another spreadsheet, and then run the import macro again.

However, I have a problem in that my import macro gives me 'Run-time error '1004:

Application defined or user defined error''. At first this wasn't a problem as the information is pasted into the spreadsheet despite the error anyway. However, now that I am looping the macro it is obviously causing more problems as it prevents the loop. I would really appreciate it if anyone knows of a work-around or can spot an error in the coding to resolve this!

The code below shows is for the import macro only:

Sub ImportTextFile(FName As String, Sep As String)

Dim RowNdx As Long
Dim ColNdx As Integer
Dim TempVal As Variant
Dim WholeLine As String
Dim Pos As Integer
Dim NextPos As Integer
Dim SaveColNdx As Integer

View 8 Replies View Related

Import Multiple Text Files

Dec 11, 2007

I have about 200 text files each with 2 columns. I want to create a single excel spread sheet where the data comprises of the second column from each text file. I do not know any thing about macros and so need help on writing a macro that will automatically import data from the whole of the second column of each text file into one single spread sheet.

View 7 Replies View Related

Import Multiple Text Files Into Spreadsheet?

Dec 22, 2011

I have about 10k poorly formatted txt files that I need to grab 4 items from each and put in a spreadsheet. How can this be done in Excel or should it be done in Access instead?

Here's a link to what each txt file looks like: MTRP88PF700721.txt

I only need the number next to Posting Journal on line 3 (12686 in this case), the 3 digit number next to Class Total on line 11 (101 in this case), the Extended Cost Final Total and the Extended Retail Final Total (23.77 and 39.30 in this case)

because one of my staff members is currently opening each txt file and typing these figures into a spreadsheet!

View 7 Replies View Related

How To Import Multiple Text Files In One Shot

Feb 26, 2012

Need to import multiple text files in one shot. (Excel only allows 1 at a time)

Most file names are similar just numbered. ex. JoeBlowfile 1.txt, JoeBlowfile 2.txt, JoeBlowfile 3.txt, etc......

All text files have 30 lines of text

For example: JoeBlowfile 1.txt will start at A1 and end at A30, then JoeBlowfile 2.txt starts at A31 and ends at A60 and so on.....

May need to import 1 to 10000 files at a time.

all in 1 row single line starting at A1

once all files are imported need to export to 1 single text file file saved in XXXX folder with XXXX.txt name.

View 6 Replies View Related

Import Multiple 1 Column Text Files

Feb 29, 2008

rearrange this macro for me that I could import multiple txt (200 files) files from selected folder. Could You insert appropriate comments in Your altered macro
- where I should change how many columns I need to import from files,

- which column/columns I want to import from files

- macro should automatically import data from the whole of the selected column or columns of each text file into one single spread sheet and import it to different columns

I have found this:

Sub test()
Dim myDir As String, fn As String, ff As Integer, txt As String
Dim delim As String, n As Long, b(), flg As Boolean, x, t As Integer
myDir = "c: est" '

View 9 Replies View Related

Import Multiple Text Files To One Sheet

Dec 15, 2009

i am looking for a macro that would import chosen multiple text files and append them all into one worksheet into column B (one textfile row into one cell), with column A displaying the imported filename next to every entry.

View 5 Replies View Related

Import Multiple Text Files Into Workbook

Jan 23, 2010

I found the code below on the internet and adjusted it to my needs.It is working perfectly fine except for the fact that it opens a new workbook to import the data. I run this code from a workbook named "InstronImport.xlsm" and would like it to add the data in this workbook instead of a new one. I have been trying for a day now and can't seem to figure out how to do it.

Sub ImportRawFilesInstron()
Dim FilesToOpen
Dim x As Integer
Dim wkbAll As Workbook
Dim wkbTemp As Workbook
Dim sDelimiter As String
On Error Goto ErrHandler
Application. ScreenUpdating = False
sDelimiter = ","
FilesToOpen = Application. GetOpenFilename _
(FileFilter:="Text Files (*.raw), *.raw", _
MultiSelect:=True, Title:="Text Files to Open")...................

View 4 Replies View Related

Import Multiple Text Files To 1 Worksheet

Oct 25, 2007

I am trying to convert multiple tab-separated text files into one worksheet. All the text files have the same format and file structure. I have been copying and pasting these files into an Excel spreadsheet but this is time consuming. I need to find out if anyone has any ideas on how to accomplish this task using a VBA macro.

View 3 Replies View Related

Import Text Files Into Multiple Sheets

Jan 4, 2008

Trying to import mutliple text files from one folder and save them into multiple tabs in the workbook. Found this piece of code on forums but can't respond to thread since its expired. Whenever i choose a file from the folder, it would say no files exist. Is there something wrong or am i missing libaries to run this?

Sub Test()
'First off, this will prompt where the text files are saved
filepath = Application. GetOpenFilename("Text Files (*.txt), *.txt", , "Where are your text files saved")

'this will strip the filename from your selection, leaving just the folder
Do While Right(filepath, 1) <> ""
filepath = Left(filepath, Len(filepath) - 1)
Loop

'This will search for all of the files within the folder
Set fs = Application.FileSearch
With fs...........................

View 3 Replies View Related

Import Multiple Text Files Without Header

Apr 25, 2008

Import Mulitple Single Column Text Files

The code by Jindon works but only for the text files that do not contain a header. Can someone please telll me what I have to change in the code to make the code skip the header information (1st three line) when importing? Currently, if I use Jindon's code, it fails once it tries to import one of these text files. Here is Jindo's
Sub test()
Dim myDir As String, fn As String, txt As String, x
myDir = "c: est" '<- change to actual folder path
fn = Dir(myDir & "*.txt")
Do While fn <> ""
txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
x = Application.Transpose( Split(txt, vbCrLf))
Sheets(1). Range("a" & Rows.Count).End(xlUp)(2).Resize(UBound(x,1)).Value = x
fn = Dir()
Loop
End Sub

View 9 Replies View Related

Automate Import Of Multiple Text Files

May 29, 2008

I am new to VBA coding. My boss recently handing me a task where I have to take data which is stored in thousands of fwd files and import it into spread sheets. This can be read with notepad as plain text. This data has about 35 lines of heading info i need to skip. The data i need transfered is stored in columns and each data row is tagged at the beginning with the letter D and comment lines begin with the letter C. The heading info has no such tags.The data is space delimited. Further, some of the columns of data need to be omitted in the spreadsheet. Each data.fwd file gets its own spreadsheet meaning each time i import data i start with a fresh template.xls to import into. The format of the spreadsheet is the same as the format the data is presented in the text file with ten columns, except the text has twelve and two of them need to be omitted.

One more thing, I need to be able to push a button and query the file to import.

View 7 Replies View Related

Import Specific Line From Multiple Text Files

Aug 13, 2008

I have many text files ~5000 and I am searching for a macro that can import multiple files and also search the text file only importing two specific rows (error files may will not have 42 rows) while listing the file name in an adjacent cell.

So in column A I would like the file name, in column B any data in line 42 of the text file and in column C any data in line 43 of the text file.

Here is an example of the data in rows 42 & 43:
11 Waratah Street Mona Vale(2103) - Australie
-33.68 (-33°40') | 151.30 (151°18')

So far I have found the code below that will import all text files into one sheet but it does not satisfy my requirements.

View 9 Replies View Related

Import Multiple Text Files & List Names

Sep 19, 2007

I am a complete novice with VBA and would like to write a macro that will allow me to import multiple text files stored in a folder on my directory into a single excel worksheet. I would also like the name of each text file to be output in a separate column for each row of data in the worksheet i.e. each row is 'named' with the title of the file it comes from.

The text files are comma delimited and have 5 fields e.g.

.000071 ,93018.3,53.3583924, -6.3578328,Differential

View 9 Replies View Related

Pick Folder & Import Multiple Text Files

Oct 17, 2007

Import Multiple Text Files & List Names

I would like to use FileDailogFolderPicker object to prompt the Excel User (me!) to browse to the location of the folder which is required to execute the code below; at the moment I have to change the file path in the VBA code each time I run the macro. The code is run on a Click Event button at present.

Private Sub GetGPCFiles_Click()
test
End Sub

Sub test()
Dim myDir As String, fn As String, ff As Integer, txt As String, a()
Dim x, i As Long, n As Long, b(), t As Long
myDir = "Y:DCCRSP07RSPWE191007131007GPC" 'Have to input this path manually
fn = Dir(myDir & "*.gpc")
Do While fn <> ""
ff = FreeFile
Open myDir & "" & fn For Input As #ff
Do While Not EOF(ff)
Line Input #ff, txt
x = Split(txt, ",")
n = n + 1
Redim Preserve a(1 To n)
a(n) = x
Loop

View 6 Replies View Related

Import Text Files Into Sheet Based Last Month (name File)

Aug 15, 2014

All my files is in C:UsersmarrecoDownloads All files has name formatt (yyyymmdd) -> 20140814 I need import only last month files

Every day a system plays text files within the (C: Users drake Downloads ) folder.

E.g. I have to import only the files that have the name (yyyymmaa) based on last month.

[Code] ......

View 14 Replies View Related

Read And Import Multiple Text Files Into Excel And Parse Data?

Mar 27, 2014

I am trying to determine a way to quickly import data from text files into Excel and place data in suitable columns (under correct headings). I am thinking I could be asked which file to read and import doing them 1 by 1, or if there is an automated way to cycle through all the files that would be more efficient (filenames are variable).

From the text files I have attached I can tell the column headers and what data should go under each. Not sure how you would describe the delimiting on these files? Are these files in a format that VBA could be used to reduce manual copy and paste approach? I have about 300 of these files I want to extract the data from.

Note: the attached files are from a public access website.

WELLS0214.TXT WELLS0106.TXT

View 4 Replies View Related

Import Multiple Text Files - Delete Rows Between Lines With File Name

Apr 10, 2014

I have around 50 text files with similar design per attached file. I need to import the text files with criteria below:-

1. include file name
2. let user choose the folder
3. exclude data from "work in process summary" to "work in process cost totals"
4. only have one title in the excel files which all text files is combined "Item, Line ....."
5. If the text files do not have title like "Item, Line, ..." do not import

Is it possible to have all criteria listed above by running a macro?

A.txt

View 1 Replies View Related

To Import Several Files Depending On Date

Jun 1, 2009

I am trying to import a several files depending on date. The first part of the name of the files that I am importing are always the same, the end changes as the date changes.
I have a user form that comes up and I pick the dates that I am looking at.

What would be the code to import those depending on the date that I pick?

When my UF comes up, I pick whatever dates, I need to import all the files in between those dates.

View 11 Replies View Related

Import Multiple Files

Sep 18, 2008

I need to import about 1500 HTML file into a DB (SQL Server). But (here is the big problem), I only need to import some data of each HTML file (always the same line/variable).

So I thought using Excel as you can say with part of the HTML file you want to import. It works great.

But I did it with one file. Is there a way you can select a whole directory and it does it for you?

View 9 Replies View Related

Import Multiple .xls Files

Nov 20, 2007

I have a question regarding importing data. What I need to do is specify a certain directory and this directory contains multiple Excel files. I would like to open each file and extract certain data from each workbook. I should be ok to figure that part out (the data extraction) but I am really confused on how to open each excel file in the directory.

View 3 Replies View Related

VBA Macro To Multiple Text Files Based On Headings On Worksheet

Apr 2, 2009

I have created an Profit&Loss excel sheet with all the accounts in column A and then the values for each month, January to December in column B to column K like this:

Column A...............Col B............Col C........Col D........Col E.....and so on
Account 1..............2222............58452........5255.........5844....
Account2................5.................45...............25...........458 ....

I've made a macro that creates a textfile and saves it on my desktop, but I get a text file with all the info in the same file, what I want is to get one text file for every month, that is text file number one(january) is: The heading info+column A+columnB

text file number two(February) is: The heading info+column A+columnC
text file number three(March) is: The heading info+column A+columnD and so on

In the heading info I have to state the period and then I need the macro to change this for every text file, that is for the january file it has to be "1 to 1", for february "2 to 2" and so on. As it is now it will always say "1 to 1" because that is the values I have entered.

Sub btnSkapaFil_Klicka()
Dim strAnv As String
Dim strBeloppJan As String
Dim strBeloppFeb As String
Dim strBeloppMars As String
Dim strBeloppApr As String
Dim strBeloppMaj As String
Dim strBeloppJun As String
Dim strBeloppJul As String
Dim strBeloppAug As String
Dim strBeloppSept As String
Dim strBeloppOkt As String
Dim strBeloppNov As String
Dim strBeloppDec As String
Dim strSavepath As String
Dim intRad As Integer
Dim intStartrad As Integer
Dim intSlutrad As Integer
Dim fs, a
strOrder = Range("I2")...............

View 2 Replies View Related

Code To Import Text Files ...

Jul 17, 2006

I am trying to write a macro which creates a new worksheet with the name kenmerk (i) and then import five different textfiles in this worksheet.

I was wondering how to define the name of the textfiles in the code. The code I get with record macro is: ...

View 6 Replies View Related

Automated Import Of Multiple TXT Files?

Jan 9, 2014

I import into my website a standard .csv file that contains product details from my supplier. Columns contain info such as RRP, Wholesale Price etc and rows for each product. For some reason thats only known to my supplier the text descriptions of each of the products are held on a seperate .txt file, in a separate folder with the .txt filename recorded one of the columns cells, one for each product. There are 1000's of products, each with its own .txt file such as 38675.txt, 37828.txt. As you can imagine to copy and paste into each products cell or to manually import each .txt will take the rest of my life.

how I could automate the input of the diferent .txt contents into the required cells.

View 9 Replies View Related

Import X Columns From Multiple Files

Jan 12, 2008

i have five different formats of data files i.e. different columns in count as well as heading. i want to import selected six columns from every file in a single sheet for data manipulation. can this be done anyways. The format for result file is standard with six columns only.

View 4 Replies View Related

Import Data From Text Files Into Excel

Nov 11, 2011

I found a good piece of code to import data from text files into excel. they are delimited

I keep getting an overflow error, and then I get the error that the file is already open?

Option Explicit

Sub OpenTextFiles()
Dim strFiles() As String
Dim strFName As String
Dim strFPath As String
Dim IntFile As Integer
Dim sep As String
'define the directory
strFPath = "C:UsersXXXXXDesktopHOLDINGTEXT into Excel"

[Code] ..........

View 9 Replies View Related

Import/merge Tab Delimited Text Files

Sep 9, 2006

is there any way for a worksheet to import and merge (append) tab delimited files from these directories:

C:TempmergeVŽ‘—¿šñdata.txt
C:TempmergeVŽ‘—¿šñ (2)data.txt
C:TempmergeVŽ‘—¿šñ (3)data.txt
C:TempmergeVŽ‘—¿šñ (4)data.txt
C:TempmergeVŽ‘—¿šñ (5)data.txt

- contents of data.txt have range A1:Pn, where 'n' is last row, different for each file
- found a previous thread very similar to what i wanted, but donno how to edit this to suit my purpose
[Solved] Importing: Import many TXT files to singe workshee

BTW, does VBA recognise directory folder with unicode characters? I can rename my directory if it doesn't.

View 3 Replies View Related

Import Text Files: Delete 1st & Last Rows

Oct 25, 2006

i am importing a large number of text files from a folder into an excel worksheet (into column A) and found the following code from searching the forum.

Sub Import_Text_Files()

Const PATH = "C:Documents and SettingsSilent BazMy DocumentsElectronic Gift Card WorkTestTextFolder"

Dim My_Filenumber As Integer
Dim My_File As String
Dim My_Data As String

My_File = Trim(Dir(PATH))

If My_File = "" Then
MsgBox "No Files found matching " & PATH & My_Extension
Exit Sub
End If.......

View 9 Replies View Related

Import File Contents (XML) From Multiple Zip Files

Mar 17, 2014

My associates have saved about 2,000 .zip files in a single repository. Each zip file contains a .pdf, and a file called "metadata.xml" - the metadata files are small, only 1-2Kb.

What I'd like to do is import the contents of each metadata.xml file into a single workbook so I can build an inventory of the pdf files.

The full path looks like this:
Z:PrincetonGlobal DataFinancial DataFinancial DataWCFNDL_PRODUCTION128650_TH1X0_ProTechLLC_A_Eng_BBOT__20140317132245.195_bbot.zip

Everything up to and including FNDL_PRODUCTION is exactly the same for each file. Everything after, varies, and is not predictable.

I'm thinking there is some way to say "for each file in repository, import metadata.xml content..."

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved