Copying Data from 3 tabs into one Summary tab

philb99

Active Member
Joined
Feb 3, 2014
Messages
389
Office Version
  1. 2010
Platform
  1. Windows
Hi - I presently have 3 tabs with the same headings which represents three distinct regions in the business. The tab name is the only identifying feature and I have to add this when copying to the summary tab.

I now wish to set functionality so that all of the data feeds automatically into the Summary TAB (to save me selecting and then Copy + Pasting and ensuring I have added the Region name on after each action)

Can anyone help please?
 
OK. Good Luck with getting your solution. I'm sure that someone else has the time to recreate your data for you.
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Cannot manipulate data in a picture. Please update the data using XL2BB.
Hi Alan, with a little help I now have the addin for my v2013 although I cant actually see what to do next as nothing on my Ribbons - are you able to help please
 
Upvote 0
OK. Good Luck with getting your solution. I'm sure that someone else has the time to recreate your data for you.
Can you help Alan
Test case regions.xlsx
ABCDEFG
1ProductAmountCountry exportDateBrandRepCustomer
2Apples200Spain01/02/2021WorcesterTom Bulmers
3Pears3256France01/06/2021SurreyDaveFiat
4Cherries10234Usa01/03/2021RoseFrankYoungs
5Peaches5692Canada 01/08/2021RedsEmmaIngles
6Oranges3215Holland01/07/2021SevilleAnnThompsons
South


Test case regions.xlsx
ABCDEFG
1ProductAmountCountry exportDateBrandRepCustomer
2Apples200Spain01/02/2021WorcesterPeterBulmers
3Pears3256France01/06/2021SurreyAlanFiat
4Cherries10234Usa01/03/2021RoseFrancisYoungs
5Peaches5692Canada 01/08/2021RedsJaneIngles
6Oranges3215Holland01/07/2021SevilleAnnaThompsons
North


Test case regions.xlsx
ABCDEFG
1ProductAmountCountry exportDateBrandRepCustomer
2Apples556Spain01/04/2021WorcestercliveBulmers
3Pears8965France01/05/2021SurreyalexFiat
4Cherries14567Usa01/01/1900RosejohnYoungs
5Peaches87165Canada 01/07/2021RedsphilIngles
6Oranges258Holland01/01/2021SevillejulesThompsons
East


Test case regions.xlsx
ABCDEFGH
1ProductAmountCountry exportDateBrandRepCustomerRegion
2Apples200Spain01/02/2021WorcesterPeterBulmersNorth
3Pears3256France01/06/2021SurreyAlanFiatNorth
4Cherries10234Usa01/03/2021RoseFrancisYoungsNorth
5Peaches5692Canada 01/08/2021RedsJaneInglesNorth
6Oranges3215Holland01/07/2021SevilleAnnaThompsonsNorth
7Apples200Spain01/02/2021WorcesterTom BulmersSouth
8Pears3256France01/06/2021SurreyDaveFiatSouth
9Cherries10234Usa01/03/2021RoseFrankYoungsSouth
10Peaches5692Canada 01/08/2021RedsEmmaInglesSouth
11Oranges3215Holland01/07/2021SevilleAnnThompsonsSouth
12Apples556Spain01/04/2021WorcestercliveBulmersEast
13Pears8965France01/05/2021SurreyalexFiatEast
14Cherries14567Usa01/01/1900RosejohnYoungsEast
15Peaches87165Canada 01/07/2021RedsphilInglesEast
16Oranges258Holland01/01/2021SevillejulesThompsonsEast
Summary
 
Upvote 0
Power Query:
let
    Source = Excel.Workbook(File.Contents("C:\Users\alans\Downloads\PQ Append.xlsx"), null, true),
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Name", "Data"}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Removed Other Columns", "Data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7"}, {"Data.Column1", "Data.Column2", "Data.Column3", "Data.Column4", "Data.Column5", "Data.Column6", "Data.Column7"}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Expanded Data", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"South", type text}, {"Product", type text}, {"Amount", type any}, {"Country export", type text}, {"Date", type any}, {"Brand", type text}, {"Rep", type text}, {"Customer", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Product] <> "Product"))
in
    #"Filtered Rows"

Book2
ABCDEFGH
1SouthProductAmountCountry exportDateBrandRepCustomer
2SouthApples200Spain44228WorcesterTom Bulmers
3SouthPears3256France44348SurreyDaveFiat
4SouthCherries10234Usa44256RoseFrankYoungs
5SouthPeaches5692Canada 44409RedsEmmaIngles
6SouthOranges3215Holland44378SevilleAnnThompsons
7NorthApples200Spain44228WorcesterPeterBulmers
8NorthPears3256France44348SurreyAlanFiat
9NorthCherries10234Usa44256RoseFrancisYoungs
10NorthPeaches5692Canada 44409RedsJaneIngles
11NorthOranges3215Holland44378SevilleAnnaThompsons
12EastApples556Spain44287WorcestercliveBulmers
13EastPears8965France44317SurreyalexFiat
14EastCherries14567Usa1.2RosejohnYoungs
15EastPeaches87165Canada 44378RedsphilIngles
16EastOranges258Holland44197SevillejulesThompsons
17
North


The key to getting the Sheet names is to not let PQ automatically append the three tabs. Remove the steps except the first one and then manually highlight the first two columns and remove the other columns. Then promote the headers. Remove the duplicate headers and you have your appended data.
 
Upvote 0
Power Query:
let
    Source = Excel.Workbook(File.Contents("C:\Users\alans\Downloads\PQ Append.xlsx"), null, true),
    #"Removed Other Columns" = Table.SelectColumns(Source,{"Name", "Data"}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Removed Other Columns", "Data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7"}, {"Data.Column1", "Data.Column2", "Data.Column3", "Data.Column4", "Data.Column5", "Data.Column6", "Data.Column7"}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Expanded Data", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"South", type text}, {"Product", type text}, {"Amount", type any}, {"Country export", type text}, {"Date", type any}, {"Brand", type text}, {"Rep", type text}, {"Customer", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Product] <> "Product"))
in
    #"Filtered Rows"

Book2
ABCDEFGH
1SouthProductAmountCountry exportDateBrandRepCustomer
2SouthApples200Spain44228WorcesterTom Bulmers
3SouthPears3256France44348SurreyDaveFiat
4SouthCherries10234Usa44256RoseFrankYoungs
5SouthPeaches5692Canada 44409RedsEmmaIngles
6SouthOranges3215Holland44378SevilleAnnThompsons
7NorthApples200Spain44228WorcesterPeterBulmers
8NorthPears3256France44348SurreyAlanFiat
9NorthCherries10234Usa44256RoseFrancisYoungs
10NorthPeaches5692Canada 44409RedsJaneIngles
11NorthOranges3215Holland44378SevilleAnnaThompsons
12EastApples556Spain44287WorcestercliveBulmers
13EastPears8965France44317SurreyalexFiat
14EastCherries14567Usa1.2RosejohnYoungs
15EastPeaches87165Canada 44378RedsphilIngles
16EastOranges258Holland44197SevillejulesThompsons
17
North


The key to getting the Sheet names is to not let PQ automatically append the three tabs. Remove the steps except the first one and then manually highlight the first two columns and remove the other columns. Then promote the headers. Remove the duplicate headers and you have your appended data.
Appreciate your help Alan but as I am trying to complete this within the works IT framework they do not have the ability to download Power Query add-in - Is there another way?
 
Upvote 0
VBA Code:
Option Explicit

Sub Append()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, lr As Long, lrM As Long, s As Worksheet
    Set s = Worksheets("Master")
    For Each ws In Worksheets
        If ws.Name <> "Master" Then
            ws.Range("A1").EntireColumn.Insert
            ws.Range("A1") = "Region"
            lr = ws.Range("B" & Rows.Count).End(xlUp).Row
            ws.Range("A2:A" & lr) = ws.Name
            ws.Range("A1").CurrentRegion.Copy
            lrM = s.Range("A" & Rows.Count).End(xlUp).Row
            s.Range("A" & lrM + 1).PasteSpecial xlPasteValues
        End If
    Next ws
    Dim i As Long
    lrM = s.Range("A" & Rows.Count).End(xlUp).Row
        For i = lrM To 3 Step -1
            If s.Range("A" & i) = "Region" Then
            s.Range("A" & i).EntireRow.Delete
            End If
         Next i
         
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Completed"

End Sub
 
Last edited:
Upvote 0
Solution
VBA Code:
Option Explicit

Sub Append()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, lr As Long, lrM As Long, s As Worksheet
    Set s = Worksheets("Master")
    For Each ws In Worksheets
        If ws.Name <> "Master" Then
            ws.Range("A1").EntireColumn.Insert
            ws.Range("A1") = "Region"
            lr = ws.Range("B" & Rows.Count).End(xlUp).Row
            ws.Range("A2:A" & lr) = ws.Name
            ws.Range("A1").CurrentRegion.Copy
            lrM = s.Range("A" & Rows.Count).End(xlUp).Row
            s.Range("A" & lrM + 1).PasteSpecial xlPasteValues
        End If
    Next ws
    Dim i As Long
    lrM = s.Range("A" & Rows.Count).End(xlUp).Row
        For i = lrM To 3 Step -1
            If s.Range("A" & i) = "Region" Then
            s.Range("A" & i).EntireRow.Delete
            End If
         Next i
        
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Completed"

End Sub
Thank you Alan for your support, works perfectly.
 
Upvote 0
@philb99 in future please mark the post that helped you the most as the solution, rather than your post saying it works.
I have done it for you this time. Thanks
 
Upvote 0
@philb99 in future please mark the post that helped you the most as the solution, rather than your post saying it works.
I have done it for you this time. Thanks
Noted - its been a while since I have been on the forum and this is the first time that I read about this functionality.
 
Upvote 0

Forum statistics

Threads
1,216,085
Messages
6,128,733
Members
449,465
Latest member
TAKLAM

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