vba concatenate three (dynamic) tables into a master one - excel

I am wanting to concatenate separate tables from separate excel worksheets to create one master one.The issue with the tables is that they are dynamic ie, one table could have 100 rows, the other one could have 240, third table could have 50 for example. The tables themselves were generated by quite a few different processes, essentially they had individual filters applied and then were copied and pasted into these separate excel worksheets… ready to be used to concatenated!
I’ve managed to do all of the processes in vba so could prefer to stick with it. I don’t want to use power query (Because of connection issues and also wanted this to be automated). I also don’t want to get involved with pivot tables or do this in the sql database. This is for quite a few different reasons… and so would prefer to stick to VBA.
Ie
Table 1
Column a column b column c
Africa 100 4
Australia 0.1 5
America 200 7
Table 2
Column a column b column c
China 300 4
Australia 0.1 4
America 100 4
Table3
Column a column b column c
Bali 100 4
England 0.1 5
NZ 200 8
Result
Column a column b column c
Africa 100 4
Australia 0.1 5
America 200 7
China 300 4
Australia 0.1 4
America 100 4
Bali 100 4
England 0.1 5
NZ 200 8
If anyone has any recommendations, would love to hear

Related

Excel Pivot Table: Different Subtotals for Different Value Fields

I have an excel pivot table with two summed field values. I need to subtotal the first one using sum and the second one using average. Here is the desired output:
Region
State
SumOfSales
SumOfUnitsSold
A
NY
100
5
A
NJ
200
3
A Subtotal
300
4
B
FL
250
4
B
GA
300
2
B Subtotal
550
3
So far the closest thing I've been able to find is a custom subtotal through the field settings for Region. But this adds two rows for subtotals. Any ideas?

Sum a Column if it matches a Criteria in one formula - is it possible?

I have two columns of revenue figures of different brands: Example
US UK
Brand 1 100 0
Brand 2 200 50
Brand 3 100 40
Brand 4 0 20
What I am trying to do is SUM the UK column IF and only if US AND UK are bigger than 0 (Revenue>0), Therefore my output would be 90.
How do I do this in one formula - is it possible?
Thanks
Try SUMIFS() like.
=SUMIFS(C2:C5,B2:B5,">0",C2:C5,">0")

How to combine SUMPRODUCT with an INDEX and MATCH formula?

Note, I have edited my original question to clarify my problem:
As the title suggests, I am looking for a way to combine the SUMPRODUCT functionalities with an INDEX and MATCH formula, but if a better approach exists to help solve the problem below I am also open to it.
In the below example, imagine that the tables are on different sheets. I have a report that has the sales of each ID in the rows and each month in the columns (first table). Unfortunately, the report only has IDs and not the region they belong to, but I do have a look up table which labels each ID with their respective region (second table):
A
B
C
D
1
ID
January
February
March
2
1
10
5
20
3
3
5
5
10
4
7
0
10
5
5
14
10
25
5
6
25
5
10
10
7
27
10
10
10
8
44
5
5
5
A
B
1
ID
Region
2
1
East
3
3
East
4
7
Central
5
14
Central
6
25
Central
7
27
West
8
44
West
My goal is to be able to aggregate the sales by region as per the result below. However I would only like to show sales data that belong to the month that is shown in cell D2.
Goal:
A
B
C
D
1
Region
Sales
February
2
East
10
3
Central
45
4
West
15
I have used the INDEX and MATCH combination to return a single value, but not sure how I can return multiple values with it and aggregate them at the same time. Any insight would be appreciated!
You may just use:
=SUMPRODUCT((Sheet1!B$1:D$1=D$1)*(Sheet1!H$2:H$8=A2),Sheet1!B2:D8)
Remember, SUMPRODUCT() could be quite heavy processing huge data, therefor to combine INDEX() and MATCH() is not a bad idea, but let's do it the other way around and nest the latter two into SUMPRODUCT() instead =):
=SUMPRODUCT(INDEX(Sheet1!B$2:D$8,0,MATCH(D$2,Sheet1!B$1:D$1,0))*(Sheet1!H$2:H$8=A2))
Another option using SUMIF+INDEX+MATCH function as in
In "Sheet2" B2, copied down :
=SUMIF(Sheet1!H:H,A2,INDEX(Sheet1!B$1:D$1,MATCH(D$2,Sheet1!B$1:D$1,0)))

Excel with rows of details related to other row

There is a way to have a group of rows related to other one, in the same sheet, like a more detailed information? Obviously must keep them always next to the main row if you filter or sort.
Desired example based on vehicles and travels:
A B C D
1 [ID] [VEHICLE TYPE] [BRAND] [COLOUR]
+ 2 A-171 PICKUP HONDA BLACK
- 3 [TRAVEL] [KM] [STATION]
- 4 12/08/2016 13.000 BARCELONA
- 5 13/08/2016 13.750 DONOSTI
+ 6 B-501 VAN RENAULT WHITE
- 7 [TRAVEL] [KM] [STATION]
- 8 12/08/2016 117.800 PARIS
- 9 13/08/2016 120.000 AMSTERDAM
- 10 14/08/2016 124.320 MUNICH
So when you sort the spreadsheet, should keep always the travel rows next to the vehicle row.
It is that possible? If not, what can I do to get this or similar? (I don't mind to use other sheet tab, but it wasn't the ideal)
You can use the Group function (Alt-A-G-G), and they won't be sorted as usual if you use sort on the whole column

Excel lookup same index different row

I have a formatted table that contains information about areas, including sales for the month (and a heap of other columns containing other details). The table is the basis for graphs and pivot tables.
There is a row per month for each area, e.g.:
A B C D
1 Area Month Sales TwoMonthAverage
2 North 1 400 Manually entered
3 West 1 500 Manually entered
4 South 1 200 Manually entered
5 North 2 200 <calculate??>
6 West 2 200 <calculate??>
7 South 2 200 <calculate??>
8 North 3 100 <calculate??>
9 West 3 900 <calculate??>
10 South 3 600 <calculate??>
Each month, I want to calculate the "2 month average" sales for an area (being the average of the current and previous months).
I need to know how to get the sales for the same area for the previous month. The table rows will not necessarily be in the same area or month order. Needs to work in Excel 2013 and 2010.
Thanks
Blair
You could perhaps use SUMIFS to get the sum of the past 2 months sale:
=SUMIFS($C$2:C5, $A$2:A5, A5, $B$2:B5, ">="&B5-1)
This in D5 will give the sum of values that:
Have values in cells A above and including the current row, and
Have the month above or equal to the current month - 1.
You then only need to divide by 2 to get the 2 month average.

Resources