Stumped With Creating a Macro to Combine Workbooks

Tesla11

New Member
Joined
Jul 19, 2012
Messages
4
Hi,

I've been attempting to find a macro that would combine a number of similar workbooks into one large workbook. The files I'm dealing with are all .csv files with identical columns and headers. Let me also say, I have very little experience with these or code writing, so please be patient with me.

I found one macro here: see below (this is the start of the macro) yet either I'm not using it correctly or there are errors in it as when I run it I get an error that says Run-time error '9' Subscript out of range and gives me the option to debug it. When I choose to debug it opens up the macro and has the following section highlighted? Any help would be greatly appreciated.

Set wsMaster = ThisWorkbook.Sheets("Master") 'sheet report is built into

The macro in I found on this site begins with the following:

Option Explicit

Sub Consolidate()
'Author: Jerry Beaucaire'
'Date: 9/15/2009 (2007 compatible) (updated 4/29/2011)
'Summary: Merge files in a specific folder into one master sheet (stacked)
' Moves imported files into another folder
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi,

I've been attempting to find a macro that would combine a number of similar workbooks into one large workbook. The files I'm dealing with are all .csv files with identical columns and headers. Let me also say, I have very little experience with these or code writing, so please be patient with me.

I found one macro here: see below (this is the start of the macro) yet either I'm not using it correctly or there are errors in it as when I run it I get an error that says Run-time error '9' Subscript out of range and gives me the option to debug it. When I choose to debug it opens up the macro and has the following section highlighted? Any help would be greatly appreciated.

Set wsMaster = ThisWorkbook.Sheets("Master") 'sheet report is built into

The macro in I found on this site begins with the following:

Option Explicit

Sub Consolidate()
'Author: Jerry Beaucaire'
'Date: 9/15/2009 (2007 compatible) (updated 4/29/2011)
'Summary: Merge files in a specific folder into one master sheet (stacked)
' Moves imported files into another folder
Does the workbook that contains the macro have a worksheet in it with a tab name "Master"?
 
Upvote 0
I use batch files in this situation, no macros needed. Simply make a text file, copy the command below into it and save it as whatever.bat. place the batch file along with all the csv files into a single folder and double click the batch file and you should see a new file in the folder called importfile.csv. Very simple way to combine csv files.


copy *.csv importfile.csv
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top