Adding Workbook Name in Column and Loop

DPhilip

New Member
Joined
Jan 12, 2016
Messages
27
Hi Everyone: Can someone please point to me in the right direction? My attempt is to go through a specific folder and consolidate all the files into one workbook.

I am having three setbacks.

  • First one is I am not sure how to loop through all the workbooks.
  • Second one is adding the file name in column A so I know which workbook it came from.
  • Third is dynamically finding the Row labeled "Region" and copy below that. This row might be row 52 this month but it can change to row 45 next month..

This is what I have so far. Thank you in advance for any help.


Sub COPY_PASTE_FROM_BLUESHEET()
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
Dim wb As Workbook
Dim WbTemp As Workbook
Dim WS As Worksheet
Dim WsTemp As Worksheet
Dim Lastrow As Long
Dim X As Variant
Sheets("Step 2").UsedRange.ClearContents
Set wb = Application.Workbooks.Open(Worksheets("Step 1").Range("B6"))
Set WS = wb.Sheets("Regional Estimates")
Set WbTemp = ThisWorkbook
Set WsTemp = WbTemp.Sheets("Step 2")
Lastrow = WsTemp.Range("B2")
'IF Cells.Find("Region Program").Offset(-4, 0)
WS.Range("B52:J500").Copy WsTemp.Range("B2")
ActiveWorkbook.Close


END SUB
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,215,221
Messages
6,123,701
Members
449,117
Latest member
Aaagu

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