Combining Data from Multiple Closed Files in Folder

M

Monk

I am attempting to combine data into one excel file from multiple csv files
which are all stored in the same folder. As the csv data is all on the first
sheet of each file, I just want to paste the data from each file into the
first sheet of an excel file called Master.xls. The data can just be pasted
into the next blank cell.

I am attempting to run the following code from Ron De Bruin but I get a
Compile Error Sub or function not defined warning on Get_File_Names. Any
suggestions as to my error would be appreciated.

Sub RDB_Merge_Data()
Dim myFiles As Variant
Dim myCountOfFiles As Long

myCountOfFiles = Get_File_Names( _
MyPath:="F:\Home\Paul\Test", _
Subfolders:=False, _
ExtStr:="*.csv", _
myReturnedFiles:=myFiles)

If myCountOfFiles = 0 Then
MsgBox "No files that match the ExtStr in this folder"
Exit Sub
End If

Get_Data _
FileNameInA:=True, _
PasteAsValues:=True, _
SourceShName:="", _
SourceShIndex:=1, _
SourceRng:="A:G", _
StartCell:="", _
myReturnedFiles:=myFiles

End Sub
 
J

Jim Cone

Looks like you didn't copy all of the code.
It appears there is a Function called Get_File_Names and
a Sub called Get_Data that you would need to add to your module.
--
Jim Cone
Portland, Oregon USA



"Monk" <[email protected]>
wrote in message
I am attempting to combine data into one excel file from multiple csv files
which are all stored in the same folder. As the csv data is all on the first
sheet of each file, I just want to paste the data from each file into the
first sheet of an excel file called Master.xls. The data can just be pasted
into the next blank cell.

I am attempting to run the following code from Ron De Bruin but I get a
Compile Error Sub or function not defined warning on Get_File_Names. Any
suggestions as to my error would be appreciated.

Sub RDB_Merge_Data()
Dim myFiles As Variant
Dim myCountOfFiles As Long

myCountOfFiles = Get_File_Names( _
MyPath:="F:\Home\Paul\Test", _
Subfolders:=False, _
ExtStr:="*.csv", _
myReturnedFiles:=myFiles)

If myCountOfFiles = 0 Then
MsgBox "No files that match the ExtStr in this folder"
Exit Sub
End If

Get_Data _
FileNameInA:=True, _
PasteAsValues:=True, _
SourceShName:="", _
SourceShIndex:=1, _
SourceRng:="A:G", _
StartCell:="", _
myReturnedFiles:=myFiles

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top