This macro consolidates data from multiple worksheets into a single "Master" worksheet. It copies the header row selected by the user into the master sheet. It then loops through each worksheet, finds the last row and column of data, copies the range, and pastes it into the next available row on the master sheet. The master sheet is activated at the end. This allows data from different sources to be combined efficiently into a single worksheet.
This macro consolidates data from multiple worksheets into a single "Master" worksheet. It copies the header row selected by the user into the master sheet. It then loops through each worksheet, finds the last row and column of data, copies the range, and pastes it into the next available row on the master sheet. The master sheet is activated at the end. This allows data from different sources to be combined efficiently into a single worksheet.
This macro consolidates data from multiple worksheets into a single "Master" worksheet. It copies the header row selected by the user into the master sheet. It then loops through each worksheet, finds the last row and column of data, copies the range, and pastes it into the next available row on the master sheet. The master sheet is activated at the end. This allows data from different sources to be combined efficiently into a single worksheet.
'loop through all sheets For Each ws In wb.Worksheets 'except the master sheet from looping If ws.Name <> "Master" Then ws.Activate lastRow = Cells(Rows.Count, startCol).End(xlUp).Row lastCol = Cells(startRow, Columns.Count).End(xlToLeft).Column 'get data from each worksheet and copy it into Master sheet Range(Cells(startRow, startCol), Cells(lastRow, lastCol)).Copy _ mtr.Range("A" & mtr.Cells(Rows.Count, 1).End(xlUp).Row + 1) End If Next ws