Hi,
I've been working on creating a macro to merge data from multiple worksheets to a "master" and found a script that works but rather than putting each sheet's data at the end of the previous it's overwriting it. Does anyone know how to fix this script so it puts the data at the end of the active worksheet?
Sub MergeSheets2()
Const sRANGE = "A1:Z100"
Dim iSheet, iTargetRow As Long, oCell As Object
Dim iTop, iLeft, iBottom, iRight As Long
'Sheets(1).Select: Sheets.Add
Sheets(1).Select
Cells.Select
Selection.Clear
iTargetRow = 1
For iSheet = 2 To ThisWorkbook.Sheets.Count: DoEvents
Sheets(iSheet).Select
Range(sRANGE).Select
Selection.Copy
Sheets(1).Select
Cells(iTargetRow, 1).Select
ActiveSheet.Paste
If bRowWasNotBlank Then iTargetRow = iTargetRow + 1
bRowWasNotBlank = False
Next
End Sub
I've been working on creating a macro to merge data from multiple worksheets to a "master" and found a script that works but rather than putting each sheet's data at the end of the previous it's overwriting it. Does anyone know how to fix this script so it puts the data at the end of the active worksheet?
Sub MergeSheets2()
Const sRANGE = "A1:Z100"
Dim iSheet, iTargetRow As Long, oCell As Object
Dim iTop, iLeft, iBottom, iRight As Long
'Sheets(1).Select: Sheets.Add
Sheets(1).Select
Cells.Select
Selection.Clear
iTargetRow = 1
For iSheet = 2 To ThisWorkbook.Sheets.Count: DoEvents
Sheets(iSheet).Select
Range(sRANGE).Select
Selection.Copy
Sheets(1).Select
Cells(iTargetRow, 1).Select
ActiveSheet.Paste
If bRowWasNotBlank Then iTargetRow = iTargetRow + 1
bRowWasNotBlank = False
Next
End Sub