Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Read in Data

He All, im looking to read in data from csv files contained in approx 110
files. the files are all set up the same way and i want to calculate a
summary of each file and then "upload" this summary into a single excel file.
I presume the only way of doing this is through VBA. I can use VBA but am not
competent so the easiest way is the best.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Read in Data

Try this. It iwll open a dialog box to let you select a folder

Sub MakeSummary()


Dim lngCount As Long

' Open the file dialog
Set folderPicker = Application.FileDialog(msoFileDialogFolderPicker)
With folderPicker
.InitialFileName = "c:\temp\"
.Show
If .SelectedItems.Count = 0 Then

MsgBox ("Cannot Get foler - Exiting Macro")
Exit Sub
End If

Folder = .SelectedItems.Item(1)
Folder = Folder & "\"

End With

FName = Dir(Folder & "*.csv")
Do While FName < ""
Set NewSht = ThisWorkbook.Sheets.Add()
NewSht.Name = FName
LastRow = NewSht.Range("A" & Rows.Count).End(xlUp).Row
If LastRow = 1 And NewSht.Range("A1") = "" Then
NewRow = 1
Else
NewRow = LastRow + 1
End If

With ActiveSheet.QueryTables.Add( _
Connection:="TEXT;" & Folder & FName, _
Destination:=NewSht.Range("A" & NewRow))
.Name = FName
.SaveData = True
.AdjustColumnWidth = True
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh BackgroundQuery:=False
End With

FName = Dir()
Loop

End Sub


"Ronan" wrote:

He All, im looking to read in data from csv files contained in approx 110
files. the files are all set up the same way and i want to calculate a
summary of each file and then "upload" this summary into a single excel file.
I presume the only way of doing this is through VBA. I can use VBA but am not
competent so the easiest way is the best.

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read data Edmund Excel Programming 1 June 12th 06 07:39 AM
read odbc data William[_8_] Excel Programming 1 April 25th 06 05:59 PM
read serial data How can I Read Serial Data Excel Programming 4 June 8th 05 10:47 PM
Read data into Excel from COM!? Russell Seguin Excel Discussion (Misc queries) 1 March 31st 05 09:27 PM


All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"