Extracting data from excel workbooks to single excel spreadsheet

detailstx

New Member
Joined
Aug 6, 2010
Messages
20
Hello,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
I am a complete novice with writing macros and am hoping someone here can help me out.
<o:p></o:p>
I have a working folder (named “Tracking”) that contains a “New” folder, “Archived” folder and Master.xlsx workbook. Occasionally, randomly named workbooks will be dropped into the “new” folder. My goal is to get a macro that will extract data from sheet1 of the randomly named xlsx workbooks, and paste it into Master.xlsx workbook, allowing me to accumulate the data over time. Once the data is stored into the Master.xlsx workbook, rename the randomly named workbook (with “_archived” following name) and throw it in the “archived” folder.<o:p></o:p>


Master.xlsx is formatted (text and numbers) the same as Sheet1 (rows/columns) of the randomly name workbooks in the “new” folder. Problem is that the data varies in all of the randomly named workbooks (Sheet1), from A1 to dozens of columns and rows.<o:p></o:p>


Is this possible or am I dreaming? <o:p></o:p>


Appreciate any help.<o:p></o:p>
 
Here's a macro for collecting data from all files in a specific folder.
Unprotect them, if needed:
Rich (BB code):
            Set wbData = Workbooks.Open(fPath & fName)  'Open file

        'This is the section to customize, replace with your own action code as needed
            With wbData.Sheets("Data")
                .Unprotect
                LR = .Range("A" & .Rows.Count).End(xlUp).Row  'Find last row
                If NR = 1 Then                                'copy the data AND titles
                    .Range("A1:A" & LR).EntireRow.Copy
                Else                                          'copy the data only
                    .Range("A2:A" & LR).EntireRow.Copy
                End If
            End With
            .Range("A" & NR).PasteSpecial xlPasteValues       'paste values into master
            
            wbData.Close False                                'close file


Also do the filenames for each file to be copied need to be listed in the code?

Heh, no, that would be awful. Remember what I said originally:
Here's a macro for collecting data from all files in a specific folder....

Spend some time just reading the code and the comments in the code so you can see what exactly it does at each point as you decipher how it does it.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

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