Excel/Consolidation Macro Problem with different sheet names
QUESTION: Hi Jan,
Could you please suggest me a macro that pulls particular data from different sheets and paste it in a single sheet. I have macro for consolidation but there is a problem. We will get report from market every week. So we need to consolidate the data manually. The sheet name and sheet count will differ (Eg: this week we may get 10 sheets with some name and next week 13 sheets with some other names) all the time.
So I could not able to prepare a macro to pull the data. Kindly suggest me a macro to resolve this issue. Thank you.
ANSWER: If this is simply a macro to open each file and pull the data onto one main sheet, then it's a relatively simple process. The steps are
for every file in the folder
for every worksheet in the file
copy the data to the storage file on the first blank row
repeat until done
I can write a macro for you if needed.
---------- FOLLOW-UP ----------
QUESTION: Hi Jane,
Could you please suggest me a consolidation macro. We will receive the weekly report with 50-60 pages. In each Sheet, contents remains same as shown in the image. But the problem is, each week, the sheet name will change and sheet count will also change (for example if this week, I have received report with 56 sheets, next week it may differ as 53 sheets or 58 sheets etc). So I could not able to make a consolidation macro.
Kindly suggest me a macro to consolidate the content from different sheets to one main sheet (in another excel). Thank you in advance.
Dim NewBook As Workbook, CurBook As Workbook
Dim OutVar As Long
Dim Looper As Long
OutVar = 1
Set CurBook = ActiveWorkbook
Set NewBook = Workbooks.Add
For Each sh In CurBook.Sheets
For Looper = 1 To sh.Cells.SpecialCells(xlCellTypeLastCell).Row
NewBook.ActiveSheet.Cells(OutVar, 1).Value = sh.Cells(Looper, 1).Value
NewBook.ActiveSheet.Cells(OutVar, 2).Value = sh.Cells(Looper, 2).Value
NewBook.ActiveSheet.Cells(OutVar, 3).Value = sh.Cells(Looper, 3).Value
OutVar = OutVar + 1
This macro will create a new workbook and store data from the first three columns of each sheet in the workbook that was active when the macro was run.