Importing Multiple .txt Files In One Excel Sheet From One Folder?

Sep 14, 2012

I have a folder in my D drive where I used to keep my Text files after downloading it from our support centeral. I want to Import all these Text files in one excel sheet in a way that data of each file got append in excel sheet below previous file data.I am trying to do this through FSO but unable to do the same.

View 1 Replies


Importing Specific Sheet Of Multiple XLS Files Into One

Nov 17, 2008

I know similar questions have been asked before, but I couldnt work out how it is done.
Basically I have several xls files with the same name, eg. "test" with an alternating number at the end. 1 - ....

each of these workbooks contain several sheets but all books are the same just with different information on it. each workbook has got a summary sheet in it, i want to import all summary sheets into a single workbook called summary. but each sheet should be imported as in individual sheet.

View 9 Replies View Related

Importing Range From Worksheet Of Several Files Contained In A Folder

Jun 17, 2013

I have a folder with 8 files which have different names like John-s, Joe-K, Mary-j,....

There are 14 sheets in each file. One of the sheets in the files named Daily contain information in Range A5:G16 that I need to import from all 8 files into a separate file called Import.

View 4 Replies View Related

Load Multiple Excel Files With Given Folder And Carry Out Same Macro On Them

Aug 16, 2013

i am working with a large data set of excel files . I need to format the sheets in a specified way . i have recorded a marco that does this . I now have the problem of creating an automatic loader that opens the files , carrys out my macro , then closes the files.

For example i have a folder X that has 10 files inside it. i would like to be able to load the first file , carry out the macro, close the file move it folder y . Then look back into Folder X , take the first file it see's , carry out the macro , close the file , move it folder y , the go back to folder x and carrying out this until all the files are done and stopping when the folder is empty

View 1 Replies View Related

Excel 2010 :: Macro On Multiple Files In A Folder Run Time Error 424

Jun 23, 2013

I have obtained a piece of code from online that runs a macro on multiple files in a single given a single folder. when i implement it though it throws a run time error 424 "object required' and point to 'Documents.Open FileName:=path & file' line of code. Is this because Dim file type is not declared?how do i fix this problem. also, im using excel 2010.A

Sub Mac()
Dim file
Dim path As String


View 4 Replies View Related

Excel 2010 :: Multiple CSV Files - Macro To Point Folder Where These Saved

May 11, 2012

I'm working on a project where I need to import 150 csv files into an Excel2010 workbook, with each csv file being on a seperate worksheet.

I would like to set up a macro to point to the folder I will have these saved in this up so that each month when I get updated csv files I can repeat the process and bring in the new data. how to create this, I'm very new to VBA?

View 1 Replies View Related

Excel 2010 :: Rename Files In Multiple Folders And Copy To New Folder

Sep 22, 2013

For the last year I have been downloading cash register X1 and Z1 files onto an SD card. Each night's files (X1 & Z1) are stored in a new folder with the naming convention "RP + [DATE]", (EX: RP120910, [YYMMDD]). I have 265 folders! I need to go through each folder, select the Z1 file (I don't care about the X1, X2 or Z2 files) and rename each with the following naming convention: "Z1 + folder_name + .xls". For Example: Folder RP120910 contains the Z1 file named "Z1_T1729.ECR". After renaming, the file should be "Z1RP120910.xls". As the VBA code loops through each subfolder, selecting and renaming the Z1 files, I would like the new files to be placed into a new folder named "Z1Files". Note: All subfolders are currently in a directory named "RegisterFiles". I am using Excel 2010.

View 3 Replies View Related

Excel 2003 :: Extract Variable Rows Of Cells From Files In A Folder To Existing File In Folder

Mar 15, 2013

I need a macro in a workbook to look at all the files in the same folder that have "*att*.xls" in the name and determine and copy from the range A15:W515 only the rows that have data in at least columns A, C and D. Each file will vary as to how many rows there will be and there are more than the files with "*att*.xls" in the folder. The data will be on the only worksheet in each file and the worksheet is named "G2WAttendee_xls" the data from all the files need to be copied to the file called "Consolidated webinar reports.xls" (I am using Excel 2003) and to a sheet called "Attendance Data" and added to the end of the last paste.

At the start of the macro the current file "Consolidated webinar report.xls" should be saved to a sub folder of the current directory and have the date saved added to the name. The sub folder is called "Completed reports". The data in the original file on worksheet "Attendance Data" should be deleted.

At the end of the process all the files that have had data copied from them should be moved to the sub folder "Attendance reports consolidated" (This could be done as each file is closed if that is easier).

I have headings in row 1 of the "Attendance Data" worksheet that match the headings in the various files in the folder (which will always be in row 14 of the individual "*att*.xls" files).

The folder with all the files and the "Consolidated webinar report.xls" file is at path "Z:P and S MEvaluationsWebinar series 2012-13TB".

View 9 Replies View Related

Importing Multiple Txt Files

Feb 27, 2008

I have part of macro to import a txt file into excel but it is not working as it should. It is giving me a message "This file is not a recognizable format" but its just a normal txt file. Also after it gives me this warning it will open in excel and with every new txt file it gives me this warning and after it opens it.

The code I am using is:

Sub su()
Dim oWbk As Workbook
Dim sFil As String
Dim sPath As String
sPath = "C:Historical" 'location of files
ChDir sPath
sFil = Dir("*.txt") 'change or add formats
Do While sFil "" 'will start LOOP until all files in folder sPath have been looped through Set oWbk = Workbooks.Open(sPath & "" & sFil) 'opens the file
Workbooks.OpenText (sPath & "" & sFil), Comma:=True, DataType:=xlDelimited
' do something
sFil = Dir
Loop ' End of LOOP
End Sub

In this line it gives me Runtime error 1004 Method 'Opentext' of object workbook failed:
Workbooks.OpenText (sPath & "" & sFil), Comma:=True, DataType:=xlDelimited

View 9 Replies View Related

Importing Multiple CSV Files Into Workbook

Dec 3, 2012

I have a workbook that contains over 100 worksheets with stock data and price information. It uses a screenscraper to update the workbook each day with the latest day's price, and then exports each of these .csv files into a local directory. The macro for this is working. In effect it is generating a price history file automatically in my absence for me that can be read by charting software.

What I would like though is a macro to loopthrough and backfill missing price histories on each worksheet. I have a source of .csv price histories already, but would like to avoid having to cut and paste each of the 105 files manually, as it may become a regular occurence.

Each worksheet that requires backfilling has the stock code in the cell "A2", so that can be used to search for the filename Range("A2") & ".csv"

This is as far as I have got - however it results in a runtime error (91) Object variable or With block variable not set, pointing to this line:-

VB: Workbooks.Open Filename:="D:FinancialData SheetsSpreadsheetsPension" & Ws.Range("A2").Value & ".csv"

Sub BackFillData()
Dim Ws As Worksheet
For i = 1 To 105
ActiveSheet.Name = "Fund" & i

[Code] ......

View 2 Replies View Related

Importing Multiple CSV Files Into One Workbook

Jun 15, 2013

I am troubleshooting my macro that seems to cause a data shift with the Letter "F" when I import multiple CSV files into one spreadsheet. When I go outside of the macro and record a macro and import the CSV into a workbook it works perfectly fine. But there must be something in this code that is causing the shift:

Private Declare Function SetCurrentDirectoryA Lib _
"kernel32" (ByVal lpPathName As String) As Long
Public Function ChDirNet(szPath As String) As Boolean
Dim lReturn As Long
lReturn = SetCurrentDirectoryA(szPath)

[Code] ....

I have attached an excel workbook that shows how the macro imports vs. a regular import. Why "F" is causing a shift in the data.


View 3 Replies View Related

Importing Multiple Text Files

Apr 16, 2008

This is a great bit of code (I found), to import multiple text files.

I have one small issue -

currently it imports with each file going to a new column, like this: text file1 A1:A4, txt file2 B1:B4, txt file3 C1:C4 etc etc

And eventually i risk running out of columns because I'm working with a lot of text files.

Can someone tell me what to do to modify this code so it imports like this? :
text file1 A1:D1, txt file2 A2:D2, txt file3 A3:D3 ETC ETC

.e.g. first file imports across row1, second file across row2 etc

Sub test2()
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 = "\BP1MELIS001SHARED_DATAEVERYONESolutions IntranetPriceMasterlogs" '

View 9 Replies View Related

Importing Data From Multiple Text Files

Nov 22, 2006

I have about 1200 text files with data regarding different machines.These file contain a line called 'Validation date" and also the programe number on different line.

I need a macro which will extract this date for each program number and write in excel in two columns like program number and validation date.

I have tried with some of the macro help available on this site,but I have to do this one at a time.The time required doing this way is same as going in each text file and copy/pasting in excel.Is it possible to automate this process.

View 9 Replies View Related

Importing Multiple Text Files Into One Workbook

Apr 26, 2007

I am using excel 2003. I have more than 500 text file which are result of some numerical analysis. I have another bunches of the same file number. I can record and play around with macro.

What I want to do is
-copy selected cells from imported text file in excel and paste in new or in first opened excel file. I have recorded macro for one file including importing from text to excell, copy and paste the selected file (look the macro below). But I have more than 500 files and I want to do the macro the same thing for each file in one excell file. Do i have to make one macro for each file??, that takes much more time than manual import and copy paste. The cell position and range to copy is the same, but have to be pasted in new row (in one excel summery file). The file name of each text file is different and all are in the same folder.

Sub text_to_excel()

Workbooks.OpenText Filename:= _
"I:ResearchVALERI_germinationvaleri_slopevaleri_slope_COREL_DHPoutputDSCN2589.txt" _
, Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _ ..................

View 9 Replies View Related

Convert All CSV Files In A Folder To Excel Files?

Apr 8, 2014

I is it possible to convert all comma separated text files in a single folder in to excel files. But the requirement is to have 2 sheets in each new file. first to be the full file - with all columns, and in the second sheet to keep only colum A B D G H K L M O P R S T V W from the first sheet. The second sheet name must be the same as the first one but without the first "wlist_" in the name.

One more thing. The third column in the second is called "COUL". there are short letters for colors in french

can they be converted with the sort in English like it goes:

NO = B
BA = W
RG = R
SO = P
JA = Y
BE = L
GR = G
VI = V
OR = O

Here is a link to the both CSV and an example excel file with the end result. In this example i haven`t change the shorts for the colors. It takes me too much time with the find and replace function. And at the moment i`m really pushed from time.


View 9 Replies View Related

Importing Multiple Multi-Line Text Files

Apr 30, 2013

I'm trying to create a macro that will import multiple multiline text files.

I have tried another Macro from this site however that imports the each text file into one cell, but i need each line to be in a new cell and each file to be in the same sheet.

View 10 Replies View Related

Importing Selective Lines From Multiple Text Files

Jun 18, 2009

I have many text files basically with the same data from different dates. I am trying to select specific lines from each text, one that includes ".txt" which is the date, ex: "2008_308" and one that includes the word "PIXEL" and the following 5 lines after that.

I found a very similar post to mine and someone provided the script using VB for the question. It works, but it was only for one text file. I would like to use it for multiple text files. The files are all dated, i.e. "2008_308.txt". Although some of the dates are missing.

This is the script, from another posting, for importing selective lines from one text file:

Sub test()
Dim fn As String, txt As String, delim As String, a() As String
Dim i As Long, ii As Long, iii As Long, n As Long, x, y
fn = "c: est.txt" ' İChange here (File Path)
delim = vbTab ' İChange here (delimiter)
temp = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
x = Split(temp, vbCrLf)
ReDim a(1 To UBound(x) + 1, 1 To 100)
For i = 0 To UBound(x)
If InStr(1, x(i), "txt", 1) > 0 Then
n = n + 1 : y = Split(x(i), delim)
For ii = 0 To UBound(y)
a(n, ii + 1) = y(ii)..........................

View 9 Replies View Related

Multiple CSV Files Into One Excel Sheet

Oct 18, 2011

how to import multiple (selected from a certain folder) csv files (comma delimited) into one excel sheet.This has to be done with a VBA macro by the way.

View 1 Replies View Related

Searching And Importing JPEG Files And Paths Into Excel

May 23, 2012

Am creating a large medical teaching database on Excel that lists JPEG images (a few hundred) and the file paths for each image into separate Excel columns using a VBA macro.

The JPEG image filenames are numbered in ascending numerical format (i.e 1.jpeg).

View 1 Replies View Related

Extracting / Importing Tables From Several Word Files To Excel File

Jul 17, 2013

I have several word Files which has standard letter format and contains some tables which needs to be extracted / imported to Excel sheet

The File name is "employee name" which also needs to be extracted , if possible in same excel file.

Attached is the sample of word file. There are 3 tables which needs to be extracted

I have several files and I want to avoid doing it manually.

View 2 Replies View Related

Access: VBA Combining Multiple Excel Files To 1 New Sheet

Oct 10, 2003

I have multiple worksheets spread across multiple Excel files (1 worksheet per file).

All files are stored in the same folder, and all worksheets have the same column headers and structure. I need a block of code that will combine all of these worksheets into a single worksheet in a master Excel file. That is, the code needs to:

1. Open the first Excel file.
2. Copy the first worksheet's contents into the first worksheet of the master file, beginning at the next empty row it finds.
3. Close the Excel file, and move on to the next file.
4. Repeat.

So in the end, ten worksheets residing on ten different Excel files will be combined into a single worksheet in a single file. No breaks are needed between them, instead, the last row of a worksheet would be followed by the first row of the next one immediately below it. No aggregate functions involved, no sums, nothing like that (which is why I don't think I can use the Consolidate function in Excel).

View 5 Replies View Related

VBA Open All Text Files In Excel In Folder And Save Them As Excel File

Dec 7, 2013

I have some daily text files in a folder (so about 30 of them each month), which in the end of month, I need to open them up in excel, format them so that I can use the information for my analysis.

I would like to create a macro, to quickly open them all up at once and save them each individually in .xls or .xlsm format.

I am new to VBA and after some research online, I was able to have the files open with the following code. but now I don't know how to proceed further to save them one by one with the same name but in .xls or .xlsm format.

Sub Opentxtfiles()
Dim MyFolder As String
Dim myfile As String


View 2 Replies View Related

Consolidating Folder Containing Multiple Files That Contain Same Tab Name

Aug 15, 2012

I have a folder that contains around 45 excel files, each of these files contain a tab called "corp val". (these files change name month to month e.g. Report June, Report July etc)

I am finding on a monthly basis i need to go into each of these excel files and copy the data from the "corp val" tab into a summarized spreadsheet - which i then use the data for various things.

Just wondered if there was a solution to this or will it always be difficult to copy and pasting all the data i need. I am not in anyway an advanced excel user, I am guessing this might be some form of macro in which case I am maybe better to keep doing it the way I was as I am not literate in macros.

View 1 Replies View Related

How To Modify Multiple Files In A Folder

Sep 9, 2013

I would like to know if there is a way to modify multiple excel files in a folder. What I need to do is hide various columns, adjust margins, cut and paste certain columns to a different position, and change the page layout. Is all of this possible, or will I need to change each individually? If you need more information, let me know.

View 5 Replies View Related

Running Macro Across Multiple Files In Same Folder

Apr 7, 2009

I would like my macro to go to a certain folder- in this case N:Aexeo ClientsJabre2008Excel Diet Run, open each workbook therein ( to this end I have found the first part of the code below on another thread) and perform the ExcelDietMacro (also below). I am missing something though as nothing is happening, would anyone know from a quick glance what is wrong? Should I have these as 2 seperate Sub End Subs or combined into one? I know that the Excel Diet is correct thanks to the original designer and Rory on the forum for getting it adjusted to my needs.

Also each workbook within the folder will have the same password to open, is it possible to insert some code in the macro to do this automatically?

Sub LoopFiles()
Dim MyFileName, MyPath As String
Dim MyBook As Workbook
MyPath = "N:Aexeo ClientsJabre2008Excel Diet Run"
MyFileName = Dir(MyPath & "*.xls")
Do Until MyFileName = ""
Workbooks.Open MyPath & MyFileName
Set MyBook = ActiveWorkbook
Application.Run "ExcelDietMacro"
MyFileName = Dir
End Sub

Sub ExcelDietMacro()
' ExcelDietMacro Macro.........................

View 9 Replies View Related

Rename Multiple Files In A Folder Macro

Jun 11, 2009

I have 400ish departmental budget files in a folder that I need to upload to a Sharepoint doc library. The files in the folder will have to exactly match the files we already have set up in sharepoint in order to upload them to the sharepoint site. As it stands now there is only one consistency between the sharepoint files and the budget files in the folder, which is the department number (which every file in both begins with).

I'm thinking some sort of macro will let me insert a sheet into each of the files in the budget folder, which would have a formula that pulls the department number from a certain sheet in the file, and produce the file name I want into a certain cell. Then I would like a macro that goes into each file and renames it based on that cell. I'd like to know if this is possible and if there may be a better way to do it.

View 9 Replies View Related

Build Index From Multiple Files In Folder

Dec 3, 2007

I would like to build an index sheet from multiple sheets in a folder(directory).
Let's say I have a folder with sheetA.xls, sheetB.xls and sheetC.xls. I would like to automatically create an "index" sheet that lists the sheet name and info from cells B2 and cell C3 all on a single row. So my index sheet might look something like this:

sheetA Portland Oregon
sheetB Seattle Washington
sheetC Reno Nevada

View 8 Replies View Related

Excel 2011 :: Loop Through All CSV Files In A Folder

Nov 23, 2011

I want to open all csv files in a folder and just copy and paste some columns into another file. I am having a bit of trouble with the following code which can be found at ozgrid and I have modified slightly so it looks in the current directory instead of a fixed path...

Sub RunCodeOnAllFiles()
Dim lCount As Long
Dim MyDir as string


For starters, if I don't use on error resume next I get a runtime error 445: object doesn't support this action. So when I use the on error resume next, then by the time it gets to the foundfiles line, there are no variables set, so on the next line ( nothing happens.

Is there an easier (more up to date?) method to open all csv files (or excel files) in a folder?

View 6 Replies View Related

Macro To Collate Name Of Excel Files Within Folder?

Jun 4, 2013

I have approximately 5000 excel files in a folder with which are named by cost centre e.g 45684 (all differing lengths).

some script so I run a macro and an excel sheet captures the name of every single excel file in the folder?

View 2 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()
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

View 6 Replies View Related

Copyrights 2005-15, All rights reserved