Multiple Sheet merge - VBA in Excel 2010

ShilP

New Member
Joined
Oct 8, 2015
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Hi GuysI have a workbook with multiple worksheets:Sheet 2Sheet 3Sheet 4Sheet 5Sheet 6Sheet 7Sheet 8Sheet 9Sheet 11Sheet 12Sheet 13Region1Region2Region3Region4How can I add All the data in Sheet 2 into a new worksheet called “Master”, and subsequently, add all the data in the remaining worksheets underneath the data which was just placed in the Master sheet.ThanksShil
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
think i need to work out how to create a line break in my post also. :(
 
Upvote 0
So you want to take all the data in all your sheets and put all that data into the Master sheet is that correct?
 
Upvote 0
Are all of the sheets setup the same way with the same number of columns.
Can you tell us what columns need to be copied over for example would it always be columns 1 to 6
 
Upvote 0
Yes, they are all the same. the columns i would need are 1 to 17thanksShil
 
Upvote 0
Start by creating a sheet named "Master" and then run this macro. The macro does not create a sheet called "Master" for you. Do it manually. Also you didn't specify if you had headers so I assumed you didn't. If you have headers, just change everywhere that you see "A1" and make it "A2".

Sub myMacro()
master = "Master"
lastRow = Sheets("Sheet 2").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Sheet 2").Range("A1:Z" & lastRow).Copy
ActiveSheet.Paste Destination:= Sheets(master).Range("A1")
CutCopyMode = False

For Each wksht in Workbooks
If wksht <> "Sheet 2" Then
nextRow = Sheets(master).Range("A" & Rows.Count).End(xlUp).Row + 1
lastRow = Sheets(wksht).Range("A" & Rows.Count).End(xlUp).Row
Sheets(wksht).Range("A1:Z" & lastRow).Copy
ActiveSheet.Paste Destination:= Sheets(master).Range("A" & next row)
CutCopyMode = False
End If
Next wksht
End Sub
 
Upvote 0
Start by creating a sheet named "Master" and then run this macro. The macro does not create a sheet called "Master" for you. Do it manually. Also you didn't specify if you had headers so I assumed you didn't. If you have headers, just change everywhere that you see "A1" and make it "A2".Sub myMacro()master = "Master"lastRow = Sheets("Sheet 2").Range("A" & Rows.Count).End(xlUp).RowSheets("Sheet 2").Range("A1:Z" & lastRow).CopyActiveSheet.Paste Destination:= Sheets(master).Range("A1")CutCopyMode = FalseFor Each wksht in WorkbooksIf wksht <> "Sheet 2" ThennextRow = Sheets(master).Range("A" & Rows.Count).End(xlUp).Row + 1lastRow = Sheets(wksht).Range("A" & Rows.Count).End(xlUp).RowSheets(wksht).Range("A1:Z" & lastRow).CopyActiveSheet.Paste Destination:= Sheets(master).Range("A" & next row)CutCopyMode = FalseEnd IfNext wkshtEnd Sub
Hi, thanks. Its giving me a syntax error at the following line:ActiveSheet.Paste Destination:= Sheets(Master).Range("A" & next row)Any idea how i can fix this?
 
Upvote 0
Shilp. Did you create a sheet named "Master"?

Change: (Master).Range("A" & next row)
To:

(Master).Range("A" & nextRow)
 
Last edited:
Upvote 0
Shilp. Did you create a sheet named "Master"?Change: (Master).Range("A" & next row)To:(Master).Range("A" & nextRow)
Thanks, this worked for the first Sheet. Now how can i edit this so that all Sheets Data appear underneath the master data sheet. Currently your one only shows only one worksheets worth of data. ThanksShil
 
Upvote 0

Forum statistics

Threads
1,215,347
Messages
6,124,421
Members
449,157
Latest member
mytux

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