Combine 2 sumproducts from different sheets and SUM(OFFSET(INDIRECT(ADDRESS(MATCH(CONCATENATE))) combination

mbthemis

New Member
Joined
Sep 29, 2014
Messages
9
Hi to all, and thank you for all the great solutions that you provide in this forum.

I need to calculate the following in excel 2013 win7:
Data of the 1st sheet will be pasted from another software. In it there will be data of different customers. In B column there will be CODE of the expenses and in F column the SUM. CODE of expenses will be grouped into CODE CATEGORIES in sheet2. I need to calculate for every single customer by each code category the sum .
1-So i must generate a customers list (by its vat number) from sheet 1. (i can do it manually if it cant be done automatically)
2.-I must specify the range of cells that belong to each customer and contain their data. I have come up with this formula with which i can play : =SUM(OFFSET(INDIRECT(ADDRESS(MATCH(CONCATENATE("FM: ";M1);E:E;0);5));0;0;ABS(MATCH(CONCATENATE("FM: ";M2);E:E;0)-MATCH(CONCATENATE("FM: ";M1);E:E;0));2))
the vat is given by the software in "FM: 1015151515" format.

3. In sheet 2 i have grouped each expense code by category and each category has been marked by a number (i have done this by color and a macro command but since different excel versions show colors differently, in the example the categories are numbers).

4. I have tried with sumproduct and sumif as i show you in the table below but without success. I need to calculate somehow for each client (shorted by vat numbers), the sum of expenses in sheet1 column F, (with the following conditions) by each category at sheet 2 (H1 to M1) from the expense codes in the sheet1 that belong to this category (column B in sheet1 that matches the column A in sheet2. All this must include the offset function probably so as to understand the excel how many rows belong to each client.

These are the sheets -> with the formulas:
sheet 1 starting from A1:
----------------------------------------------------------------
COMPANYFM: 149186824VAT NUMBERS FOR TEST
CREDITDEBITSUM149186824
114.00.0000DESCRIPTION338,050338,05102958444
220.00.0000DESCRIPTION93,71093,71
320.00.0013DESCRIPTION112,090112,09SUM BY OFFSET TEST
462.03.0123DESCRIPTION47,02047,02=SUM(OFFSET(INDIRECT(ADDRESS(MATCH(CONCATENATE("FM: ";H2);E:E;0);5));0;0;ABS(MATCH(CONCATENATE("FM: ";H3);E:E;0)-MATCH(CONCATENATE("FM: ";H2);E:E;0));2))
562.04.0000DESCRIPTION1.008,8001.008,80
663.04.0000DESCRIPTION290,220290,22
763.98.0000DESCRIPTION33,72033,72
864.00.1023DESCRIPTION2850285
964.08.0023DESCRIPTION55,29055,29
1064.98.0000DESCRIPTION74,95074,95
1164.98.0023DESCRIPTION1.460,0401.460,04
1273.10.0013DESCRIPTION0160,04-160,04
1373.10.0023DESCRIPTION01.217,15-1.217,15
1475.00.0000DESCRIPTION01.020,00-1.020,00
1575.00.0023DESCRIPTION01.094,00-1.094,00
---------------
DATA
COMPANYFM: 102958444
CREDIT DEBITSUM
161.92.0000DESCRIPTION451,420451,42
264.98.0000DESCRIPTION0,300,3

<colgroup><col span="7"><col></colgroup><tbody>
</tbody>
--------------------------------------------------------------------------------

sheet2 starting from A1
---------------------------------------------------------------------------------
CATEGORY DESCRIPTIONSDESCRIPTIONDESCRIPTIONDESCRIPTIONDESCRIPTIONDESCRIPTIONDESCRIPTION
CATEGORY CODES65535
102133169944516959288633424893969910
CATEGORIZATION OF EXPENSE CODESsumif test for all=SUMIF($C:$C;H2;$D:$D)
205,8
0000
DESCRIPTIONCATEGORY CODESUM BY CATEGORY ON ALL CLIENTStest sumproduct for allVAT NUMBERS PER CLIENT
DESCRIPTION65535=SUMIFS(Sheet1!F:F;Sheet1!B:B;A5)
=SUMPRODUCT((Sheet1!$F:$F);--(A5=Sheet1!$B:$B))
FM: 149186824=SUMPRODUCT(--($C$1:$C$10000=H$2);(Sheet1!$F$1:$F$10000);-($A$1:$A$10000=Sheet1!$B$1:$B$10000))
00000
DESCRIPTION655350FM: 102958444000000
DESCRIPTION655350more vat…
DESCRIPTION655350more vat…
DESCRIPTION655350more vat…
DESCRIPTION655350more vat…
DESCRIPTION1021331693,71more vat…
DESCRIPTION102133160
DESCRIPTION10213316112,09
DESCRIPTION102133160
DESCRIPTION102133160
DESCRIPTION102133160
DESCRIPTION99445160
DESCRIPTION99445160
DESCRIPTION99445160
DESCRIPTION99445160
DESCRIPTION99445160
DESCRIPTION255
0
DESCRIPTION33424890
DESCRIPTION33424890
DESCRIPTION33424890
DESCRIPTION33424890

<colgroup><col><col><col span="2"><col><col><col span="6"></colgroup><tbody>
</tbody>
------------------------------------------------------------------------------------------------------------------------------------------------
I have put the formulas in sheet1 in cell H6 and in sheet2 in cells D5, E5, H5 and H3 please copy paste the above to see it in an excel.
 
i am trying to aplly the following formula in sheet2 with reference to sheet1
=SUM(OFFSET(INDIRECT(ADDRESS(MATCH(D9;Sheet1!$B:$B;0);2;;;"Sheet1!"));0;0;10;1))
but a get a #ref! error
if i brake it it works p.e. =ADDRESS(MATCH(D9;Sheet1!$B:$B;0);2;;1;"Sheet1!") gives me a result of 'Sheet1!'$B$1
the indirect works only in this format =INDIRECT("Sheet1!B1")
is there a way to get such a result in sum offset indirect address match formula for a different sheet???
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Thank you very much Barry !!! that indeed worked, i busted my head with indirect address while index is so much flexier.

So i managed to find a formula that will calculate for every vat and every category the sum.
I ll try to describe for anyone interested.
in sheet2 in E1, is the category of the expenses code in cell D9, D10 etc are the vat numbers of each client.

So the formula is:
=SUMIFS(OFFSET(INDEX(Sheet1!$B:$B;MATCH($D9;Sheet1!$B:$B;0));0;0;MATCH($D10;Sheet1!$B:$B;0)-MATCH($D9;Sheet1!$B:$B;0);1);OFFSET(INDEX(Sheet1!$C:$C;MATCH($D9;Sheet1!$B:$B;0));0;0;MATCH($D10;Sheet1!$B:$B;0)-MATCH($D9;Sheet1!$B:$B;0);1);Sheet2!E$1)

analysis of the above:
the sum range is given by offset so as to calculate the cells only between the vat numbers that are in variable positions within the data that will be pasted in sheet1. So i match the VAT number of the 1st client (cell D9) in the sheet1 so as to start calculating from that point.
The number of rows that will calculate the sum is given by the (match - match)
(MATCH($D10;Sheet1!$B:$B;0)-MATCH($D9;Sheet1!$B:$B;0) ) at the rows part of the offset formula. In the first match i match the next clients vat row position (D10)- minus the client of calculation vat cell position (D9). (this is calculated as such because in the data sheet, after each vat start the expenses codes of each client, and they finish before the next vat)

In this part there is an unsolved problem with the last client that he has no next vat to calculate at the end. (any ideas are welcome here)

The next part of the sumifs calculation is to define the range of the criteria, which are the categories of the expenses codes that i had to index match next to the data sheet .
OFFSET(INDEX(Sheet1!$C:$C;MATCH($D9;Sheet1!$B:$B;0));0;0;MATCH($D10;Sheet1!$B:$B;0)-MATCH($D9;Sheet1!$B:$B;0);1) Again the range of the calculations is given by the formula (match - match) as above.

Here i have the main issue because so as to work all of the above, i will have to manually insert each time the index formula into the data sheet (sheet1), so as to assign to each expense code their category from sheet2, and that is not desirable. If you have any ideas on how to include (incorporate) this part to the calculation formula in sheet2 i will be so grateful !!
Is there a way to include this as criteria in my sumifs formula???
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,660
Members
449,462
Latest member
Chislobog

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