Hi Everyone,
I would like to create a vba that helps
1) Create a master sheet
2) Loop through all worksheets starting with " Data"
3) Copy column DH onwards to last column and stack them in one column on Master sheet , pasting them as values
4) If master sheet exists, to just replace data ( don't need to create again)
So far this is my code, but it only copies out column DH from each sheet, how do i extend it to other columns as well ? How can I also add point 4) to this?
Thank you in advance!!
I would like to create a vba that helps
1) Create a master sheet
2) Loop through all worksheets starting with " Data"
3) Copy column DH onwards to last column and stack them in one column on Master sheet , pasting them as values
4) If master sheet exists, to just replace data ( don't need to create again)
So far this is my code, but it only copies out column DH from each sheet, how do i extend it to other columns as well ? How can I also add point 4) to this?
Thank you in advance!!
Code:
Sub ColumnAMaster()
Dim lastRow As Long, lastRowMaster As Long
Dim ws As Worksheet
Dim Master As Worksheet
Application.ScreenUpdating = False
Set Master = Sheets.Add
Master.Name = "Master"
lastRowMaster = 1
For Each ws In ThisWorkbook.Sheets
If Left(Trim(ws.Name), 4) = "Data" Then
lastRow = ws.Range("DH" & Rows.count).End(xlUp).Row
lastRowMaster = Master.Range("A" & Rows.count).End(xlUp).Row + 1
ws.Range("DH11:DH" & lastRow).Copy
Sheets("Master").Range("A" & lastRowMaster).PasteSpecial xlPasteValues
End If
Next
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub
Last edited by a moderator: