Combine data on various sheets into one seperate sheet

MartinSpellacy

New Member
Joined
Jun 6, 2018
Messages
4
Afternoon,

I have tried recording the below macro which looks to combine the data on 9 tabs into one tab. Problem I have is that the data on each of the 9 tabs is dynamic and may vary in number of rows.

I believe I have identified the problem and have made the code bold and underlined.

Any help as to how this can work would be appreciated

Thanks
Martin



Code:
Sheets("Ab").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("Combine").Select
    Range("A2").Select
    ActiveSheet.Paste
    Sheets("Bh").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A2").Select
    Selection.End(xlDown).Select
[U][B]    Range("A237").Select[/B][/U]
[U][B]    ActiveSheet.Paste[/B][/U]
    ActiveWindow.SmallScroll Down:=6
    Sheets("Dm").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A205").Select
    Selection.End(xlDown).Select
[U][B]    Range("A782").Select[/B][/U]
[U][B]    ActiveSheet.Paste[/B][/U]
    Sheets("Dd").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A738").Select
    Selection.End(xlDown).Select
    Range("A995").Select
    ActiveSheet.Paste
    ActiveWindow.SmallScroll Down:=3
    Sheets("Gg").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A936").Select
    Selection.End(xlDown).Select
    Range("A1097").Select
    ActiveSheet.Paste
    Sheets("Gm").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A1061").Select
    Selection.End(xlDown).Select
    Range("A1302").Select
    ActiveSheet.Paste
    Sheets("Inv").Select
    Range("A11").Select
    Selection.End(xlUp).Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A1272").Select
    Selection.End(xlDown).Select
    Range("A1774").Select
    ActiveSheet.Paste
    Sheets("Nb").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A1715").Select
    Selection.End(xlDown).Select
    Range("A2246").Select
    ActiveSheet.Paste
    Sheets("VMU").Select
    Range("A18").Select
    ActiveWindow.SmallScroll Down:=-12
    ActiveWindow.ScrollRow = 4
    ActiveWindow.ScrollRow = 2
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Combine").Select
    Range("A2208").Select
    Selection.End(xlDown).Select
    Range("A2718").Select
    ActiveSheet.Paste
    ActiveWindow.SmallScroll Down:=3
 
Last edited by a moderator:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hello Martin,

Assuming that your data has headings in row1 and data starts in row2, try the following code:-

Code:
Sub Consolidate()

Dim ws As Worksheet

Application.ScreenUpdating = False

For Each ws In Worksheets
If ws.Name <> "Sheet1" Then   '---->Change "Sheet1" to the actual name of your main sheet.
       ws.UsedRange.Offset(1).Copy
       Sheet1.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlValues
       End If
Next ws

Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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