Macro To Import CSV Files Into Workbook

May 17, 2011

I'm looking for a macro that will import multiple .csv files from c: emp each into their own separate worksheet.

View 5 Replies


ADVERTISEMENT

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

Macro To Import From .csv Files

May 13, 2008

1. I've recorded a macro that imports values from 6 different .csv files at once. The problem is that not all of these files are going exist upon import. Is there a way to tell the macro to only import if the file exists? And to skip if the import of that file if it doesn't exist? Right now the debugger stops the macro because of file not found.

2. I want to press a button on Sheet 1 that copies Sheet 1 into a new Sheet that's named with today's date. E.g. I press the "Archive"-button, the sheet is copied to a new sheet with the name "051308".

View 9 Replies View Related

Macro To Import Log Files With Different Delimiters

Sep 29, 2009

I need to import a number of log files into a spreadsheet, each log will go into a separate tab. The logs are text files (.log) that have the same structure but slightly differ from each other.

For example all the logs will have many lines of data all starting with a date and then a number of delimited fields. In some logs the delimiter is a coma, in others is a unique charachter such as "{" or "@". Also the delimited fields are not a given quantity, they can vary too from log to log. How can I write a macro that understands what delimiter needs to be used and then imports all the file accordingly into one spreadsheet (in separate tabs)?

I tried something with the macro recorder and browsed for directions on the internet but really am clueless on this one. I am using windows 2000, and referenced Windows Scripting Runtime.

View 3 Replies View Related

Using Macro To Import Two Identical CSV Text Files To Make 1 Table Of Data

Apr 4, 2014

I'm having difficulty trying to get the second file appended to the bottom of the 1st imported file. I get "run-time error '13' type mismatch". There is no difference between the two files. I'm thinking there is a problem with my range statement in the second file import, but this range works fine in other macros. Here's my code so far:

Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;\server1usersmydataIMPORT1.CSV", Destination _
:=Range("$A$1"))
.Name = "IMPORT1"
.FieldNames = True
.RowNumbers = False

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

View 7 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

Add Another Worksheet & Continue Importing The Html Files Until There Are No More Files To Import

Jul 13, 2006

I'm using the following code to import thousands of html files into my spreadsheet. The code is working fine. Since I am importing thousands of files, when there is no more space on my worksheet, the code stops with an error message. I want to make this code add another worksheet & continue importing the html files until there are no more files to import.

Sub Master_Importer()
Dim I As Long
Dim strFilename As String
Dim strPath As String
strPath = "file:///C:/Documents and Settings/c/Desktop/New Folder/"
With Application.FileSearch
.LookIn = "C:Documents and SettingscDesktopNew Folder"
.FileType = msoFileTypeAllFiles
.Execute
For I = 1 To .FoundFiles.Count
strFilename = Mid(.FoundFiles(I), InStrRev(.FoundFiles(I), "") + 1)
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & strPath & strFilename _ .......................

View 5 Replies View Related

Macro To Import Data From One Workbook Into Another And Saving

Jul 3, 2014

I've got a spreadsheet listing applications on PCs (assets), one line per application, and need to import that info into another document for each PC and save it with a file name which = the PC name (asset number). I've attached a couple of sample files to try to explain what i mean.For asset number PC037014 I need the corresponding fields filled and the list of applications pasted under where is says Additional Software List (inserting more rows if there are too many applications to fit in). Once the information has been populated, i'd like the file to be saved in a specific folder then move onto the next asset number in the list.

View 13 Replies View Related

Macro Formula For Copy Cell Value From Files To One Workbook

Feb 4, 2014

Actually I do want to copy cell N589 from all files excel (sheet1) in c:database2014 to my workbook click run into the row C.

is there any of you can solve it?

View 1 Replies View Related

Excel 2007 :: Save Files XLS In Macro Workbook And Send Email

Sep 3, 2012

I am using 2007. This may be something simple but I can't seem to find a solution to this, I have an excel macro enabled workbook which produces a daily report the final task is to save and send an email but I need the file to save as an xls rather than xlsx as some of the recipients are unable to open the file here is the code used for the tasks in the

workbook:Sub Step1_Refresh()
'
' Step1_Refresh Macro
'
'
ActiveWorkbook.RefreshAll
End Sub
Sub step2_save_close()

[Code] ........

View 1 Replies View Related

Excel 2007 :: Save Files XLS In Macro Workbook And Send Email?

Sep 3, 2012

I am using 2007, I have an excel macro enabled workbook which produces a daily report the final task is to save and send an email but I need the file to save as an xls rather than xlsx as some of the recipients are unable to open the file.

Here is the code used for the tasks in the:

workbook:Sub Step1_Refresh()
'
' Step1_Refresh Macro
'
'

[Code]....

View 7 Replies View Related

Import Latest 6 Files

Feb 21, 2008

I would like to create a macro that looks in a specific directory "h:data"
It finds the 6 most recently modified files in this directory (csv files)
Then imports these 6 files into seperate worksheets in the same workbook "sorter.xls"

View 9 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

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

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 Two Lines From HTML Files

Jan 20, 2012

So I have a few thousand .html-files that i need two lines from. It is line 43 and line 46. I want those lines in each cell and the dokument name in the last cell. After that it goes 1 row down and takes the next html-file.

So it would be something like:

Row 1 | line43 | line46 | Dok1
Row 2 | line43 | line46 | Dok2

View 3 Replies View Related

Import Number Of CSV Files Into Excel?

Nov 13, 2012

I've got 80 CSV files that I need to import into an Excel sheet. The filenames are sequential, eg 1APN .... 80APN). I need each chunk of data added after the previous. How can I do this using VB?

View 2 Replies View Related

Progress Indicator On Import Files

Oct 6, 2008

I am using the following to import a text file w/ ~86000 lines into Excel: ...

View 9 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

Import Few Txt Files From One Directory To One Sheet

Jul 26, 2006

My text files look like this(each has different number of rows):
2006-08-25 13:33:20 82,8 g
2006-08-25 13:34:10 58,5 g

between each column there is Tab

To import them from one directory (directories are named as month e.g. 8) I used:

Sub Consolidate()
Dim mnthNum As Integer
Dim myBook As Workbook
Dim myRows As Long

With Application
.DisplayAlerts = False
.EnableEvents = False
. ScreenUpdating = False
End With

and it works almost perfectly.. the problem is that each time it loads next file it overwrites the previous..

e.g. if i have in my directory 4 files and sum of the rows is 20 it will show only 17. The import is good because I checked it with debugger but each time a new file is copied it starts from last row of previous file.. that's the problem I can't solve...

View 5 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 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

Mass Data Import From 200 Files. Automatically

Apr 24, 2009

I have around 200 files, all named from 001.xls to 200.xls, all containing the same format, the same number of colums, but a different number of lines.

Now I have the great task to actually open all these files and copy each files data into one file and start analyzing it. Well, since I personally have no interest to open, copy and paste 200 hundred times, I am wondering if there is any faster way to let excel automatically copy the data into this master file?
I am thinking about somehing like *='001.xls'Sheet2!B2:E20*

One thing is that each file never has more than 20 entries, thus i would only need excel to import the from line 2 to 20 from a certain file and then do same thing all over again with the next file.

View 13 Replies View Related

Mass Import Of Several Thousand Files Into One File

May 22, 2009

I am trying to do a mass import of several thousand excel files into one file. The headers of all the files are the same, but the data inside each file is different. I thought about using Access but it wants me to import each individual one.

I have zero experience in writing a Macro

View 12 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

Data Import Automation - Multiple Csv Files

Dec 6, 2009

-I receive files everyday by email and saved in a folder C:TEST
-each file saved by name Name+daily date
•( like: sale_20091214, sale_20091215, sale_20091216 )
-file is in csv/Comma delimiated format
-each file have 7 columns A to G and contain 256 rows
-i only need 7 or 8 rows & only need value in Column 'F'
-the rows i need are going to be same each time
--------------------------------------------------------------------------
I want to save automated data in a file name: MonthlySale located in c:
Fore each ROW data should be saved in new column next to last saved column.
.
Example:
data from file sale_20091214 should be saved in column B,
sale_20091214 should be saved in column C,
sale_20091214 should be saved in column D and onward.

View 8 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 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







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