Hi there,
I have the following code which works perfectly to combine and stack multiple sheet column data (35 sheets) into one Master sheet.
What I also need is for the name of each sheet to be copied down column A against each data block coming from a sheet.
Below, it brings two columns of data and pastes into A:B of Master sheet
I need column A to have SheetName and B:C to have the data?
Many thanks
Original code found here:
mrexcel.com/forum/excel-questions/404998-combining-worksheets-into-one-master-sheet.html
I have the following code which works perfectly to combine and stack multiple sheet column data (35 sheets) into one Master sheet.
What I also need is for the name of each sheet to be copied down column A against each data block coming from a sheet.
Below, it brings two columns of data and pastes into A:B of Master sheet
I need column A to have SheetName and B:C to have the data?
Many thanks
Option Explicit
Sub ConsolidateSheets()
'JBeaucaire (6/26/2009)
'Merge all sheets in a workbook into one summary sheet (stacked)
Dim cs As Worksheet, ws As Worksheet, LR As Long, NR As Long
Application.ScreenUpdating = False
Set cs = Sheets("Master")
cs.Activate
Range("A1:B" & Rows.Count).ClearContents
For Each ws In Worksheets
If ws.Name <> "Master" Then
NR = cs.Range("A" & Rows.Count).End(xlUp).Row + 1
LR = ws.Range("A" & Rows.Count).End(xlUp).Row
ws.Range("AA1:AB" & LR).Copy cs.Range("A" & NR)
End If
Next ws
Application.ScreenUpdating = True
End Function
Original code found here:
mrexcel.com/forum/excel-questions/404998-combining-worksheets-into-one-master-sheet.html