For those of us used to Microsoft Excel who switch to using Google Sheets, there are many differences which need to be taken into account.
One of the nice features in Excel that I miss is tables. If you insert a table into your Excel Spreadsheet, it does a lot of automatic things for you. You can have a single formula for one column of your table, and not have to update it whenever you add new data - whether adding a table row, or adding a row in the middle of the table.
Sometimes (though I haven't figured out why it sometimes does and why it sometimes doesn't) even without tables, Excel will suggest a formula fill as you're entering new data into a row, making copying the formula as easy as pressing "Tab".
There is no functionality in Google Sheets that matches this exactly. When you have a lot of data to enter, having to copy the formulas every single time you add a row is very tedious and time consuming and further leaves open the possibility in making a mistake when transcribing the information and copying / pasting the formulas. Any single cell could have a mistake and you won't know until it causes a problem later, then troubleshooting it will also be time consuming and difficult.
There are various questions in StackOverflow, StackExchange, Google Support and other sites that tackle this issue, but none seem to have a good solution that works for everyone. A lot of people have written an Apps Script do do just this, or use Apps Script + HTML forms as well... but it seems like that shouldn't be necessary, it adds more time & setup, and ends up with a specific solution for that sheet and that sheet only.
So, how can you replicate this behavior in Google Sheets so you don't have to keep copying & pasting your formulas over and over again and save yourself time (and your company money) and make Google Sheets act more like Excel?
BACKGROUND
There is a Google Support Thread on Inserting new Rows which suggests the use of ARRAYFORMULA to do this job. It is not an exact replacement for Excel's functionality, but it can work in most applications. There are other functions that output arrays, such as SEQUENCE which can also be applied similar to these examples depending on the situation, but I'll focus on ARRAYFORMULA here as it's the most generic and MOST functions can be wrapped in it and otherwise behave as you'd expect.
Here is also a link to an ARRAYFORMULA & MMULT Example Provided by Google (Note that this link will make a copy of the sheet, not let you directly access the example). The first tab is all about matrix multiplication, the second and later tabs have examples using ARRAYFORMULA.
The examples above are pretty limited in scope, so let's expand on those. To illustrate, I will use a basic formula involving 4 columns as an example. Let's say we have data in columns A, B, and C, and we want to do a relatively simple formula between them. Let's assume row 1 is being used as a header row, and your data is from row 2 down, as most people would do. Let's make the formula simple, but a little interesting, by having column D equal to the PREVIOUS value of A plus the product of B and C. Let's also assume we currently have 12 rows of data, but we know we will have data we need to enter in the future. Most of that data will get entered at the end, but sometimes we may need to add data in the middle of the range.
You can follow along with my Publicly Posted Example Sheet Here if you want (this will also create a copy on your drive so you can make changes and follow along). Each example below corresponds to a tab in the Example Sheet.
EXAMPLE: FORMULA ON EVERY ROW
In it's simplest form, the formula in D2 would be = A1 + B2 * C2. Except, of course, we know A1 is a text header and if we include that we'll get an error. It's also commonly understood that absolute references (with $) execute faster in Google sheets, and we don't need relative references on the columns (but rows are necessary to fill), so let's modify cell D2 as follows:
=IF( ISNUMBER($A1), $A1, 0 ) + $B2 * $C2
Then fill down to cell D13 (this is already done in the example).
So now you have your current data... but what if you need to add data?
If you add data to row 14, in columns A, B, and C, you then also have to copy the formula to D14. Easy peazy for this example, but what if you have 30 columns, 5 of them with formulas and you add another 10 entries to the list every day? This becomes very tedious. You can avoid entering it for every row, but filling down the number of rows you need today and save a little time, but it breaks your flow of data entry.
Even worse, what if the entries are in some sort of order (e.g. order of date data was captured) and you get old data that needs to be entered in the middle of the range? You can add at the end and copy, then sort.
Some sheets won't let you sort, or won't sort correctly if you have certain data, so you may need to insert in the middle... let's say between rows 8 and 9. If you did this in an Excel table, and used "insert row" it would automatically populate cell D9 with your formula.
But here, when you add this new row 9 not only is D9 blank and need you to enter the formula, but now the A column reference in cell D10 is pointing to A8 instead of A9 where it should! So you have to recopy / refill your equation to cell D10 as well - and this is easy to miss - you may not know to do it, or forget to do it, and now your formulas are broken.
... Now, to be honest, Excel didn't get this part right, either.
Somehow, it properly fills D9 in with the correct formula but botches
D10 with a reference to A8, but then continues with a correct reference to A10 in D11. Which is almost worse because since D9 was filled and all the other rows are correct, you may not realize you have a problem in D10...
This is basic spreadsheet use and is roughly the same behavior as using Excel WITHOUT Tables (except those instances where it decides to make suggestions for you) - so par for the course here if Excel didn't have the Table or suggestion ability.
Pros:
Simplest formula to implement
Works fine in fixed size sheets or sheets that don't change often
Tried and true, Will always work
Cons:
Have to copy formula to every new row you make
Very tedious for "living documents" that change often
If any formulas cross between rows, the pattern breaks when you insert a row
in between and you have to copy your formula to the row below as
well as your new one
With all the additional required repeated actions, it's very easy to make a mistake
Since the mistake could be in a single cell, finding the mistake after the fact can be difficult
EXAMPLE: CLOSED RANGE ARRAYFORMULA
Google support touts this as the best method. Indeed, if you want your formulas to update automatically when you add data in between and you want the least amount of computation time, then an ARRAYFORMULA with a limited (or "closed") range is the best solution.
To use ARRAYFORMULA, you put the formulas only in your top row of data (in this example, row 2). What makes this example closed range is that we will set it to cover exactly the data we have. So, the formula in D2 would be:
=ARRAYFORMULA( IF( ISNUMBER( $A$1:$A$12 ), $A$1:$A$12, 0 ) + $B$2:$B$13 * $C$2:$C$13 )
Here, we can (and I recommend) use all absolute references as the range we're using doesn't change as the cell row it's calculating changes. When you enter this formula, you will see it automatically populate D3 through D13 with the correct data as well.
If we want to add another row in the middle, it's easy. Taking the previous example, if we add a row between rows 8 and 9, you will see the formula in D2 has changed all the last rows - 12 is now 13, and 13 is now 14. When you enter data into columns A, B, and C in the new row 9, it automatically calculates correctly in D9.
When you look at the data in rows in column D (except D2), however, it shows the number itself in the formula bar - so someone looking at this sheet unaware there is an ARRAYFORMULA in use has no indication that it's an ARRAYFORMULA and overwriting ANY cell that was populated by ARRAYFORMULA will break the formula, give you an error in D2 and leave the rest of the values in the column blank. This is true for all methods using ARRAYFORMULA So, for that reason, I recommend you make your column a protected range!
Alternate: You could name all of your ranges. For example, $A$1:$A$12 could be col_A_prev, $B$2:$B$12 could be col_B, and $C$2:$C$12 could be col_C. Which gives the formula:
=ARRAYFORMULA( IF( ISNUMBER( col_A_prev ), col_A_prev, 0 ) + col_B * col_C )
The behavior would be identical. When you add a row in between, the named ranges will automatically expand to include it. You could also use the same ranges for your column protection to ensure no data is written over.
Note: I do want to give kudos where it is due. Google Sheets handles named ranges WAY better than Excel. When you add or remove rows / columns inside your named range in Google it automatically expands the range - and Google actually allows you to use the named ranges as references in any of the settings (conditional formatting, protection, etc.). While you can enter a named range in Excel for some of these, it will convert it to R/C references which won't change even if your range changes later. If you want to add to the ends or you move rows / columns in your named range - well, they're both still terrible at that
However, if we want to add new data to the end, in row 14 or after, this arrayformula will not automatically update.
Even worse, if you add a row between rows 12 and 13, it breaks the formula - as the references to columns B and C will update, but the references to column A will not - because A only went to row 12. In row 14 you now get the error:
Array arguments to ADD are of different size.
Because you're trying to add an array with 12 elements to an array with 13 elements. Admittedly, this is only a problem if you're referencing other rows which isn't that common across all useful spreadsheets. However, there are many practical reasons to do so, like cumulative sums.
So, either you have to deal with updating your ARRAYFORMULA columns each time you add data to the end (which doesn't make it much better than just copying your formulas to each row) or, you could basically make the last two rows "dummy rows" that you don't care about and add protection to those rows so they can't be edited or a row added between them, with perhaps a note saying "To add new data, insert a row above this line" so other people using it know what they have to do.
Pros:
Relatively simple formula to implement
Fastest Execution time
Will automatically adjust formula to any rows added in the middle
Can manage your ranges as named ranges
Cons:
Have to change the formula if you add any new data to the bottom (which is where you usually add new data) -OR- you have to implement one or more blank rows included in range with protection & reminders to ensure no one adds data to the bottom
Data below ARRAYFORMULA looks like just number entries and could easily confuse people into thinking it's not a formula entry and overwrite it without thinking.
EXAMPLE: OPEN RANGE ARRAYFORMULA
If you're following along in the example sheet, the first thing you'll note is this sheet doesn't do the same thing. It is simply using the CURRENT value in column A, rather than the previous row. This is because you CAN'T reference a previous row with this method (see a couple paragraphs down for why). To compensate, I forced A, B, and C to 0 in the first row and added another row to the bottom.
This is similar to the closed range example in its application of ARRAYFORMULA the difference here, is instead of having a fixed end to the ranges (rows 12 & 13 above), you leave the range open by using just the column letter at the end of the range, which references the last row of the column. So the equation in D2 now looks like this:
=ARRAYFORMULA( IF( ISNUMBER( $A$2:$A ), $A$2:$A, 0 ) + $B$2:$B * $C$2:$C )
The reason you can't reference a previous row's cell is if we used $A$1:$A here, that array would always have one more element than either $B$2:B or $C$2:$C and thus won't be able to add and will result in the error:
Result was not automatically expanded, please insert more rows (1).
Except inserting more rows won't work because the ranges will all expand by 1 also. Again, this is only a problem if you need to reference other rows which isn't common but is useful for things like cumulative sums.
When it comes to adding rows, though, this method is the best. Whether you are adding to the middle or the end of your data, it will automatically update the values in your ARRAYFORMULA columns.
Alternate: Same as with closed ranges, you could name all of your ranges. For example, $A$1:$A could be col_A_prev, $B$2:$B could be col_B, and $C2:$C could be col_C. Which gives the same formula as with closed range:
=ARRAYFORMULA( IF( ISNUMBER( col_A_prev ), col_A_prev, 0 ) + col_B * col_C )
So if you're not referencing previous rows, or if you just add a top "dummy" row like I did in the example, it's all good... easy peazy lemon squeezy, right?
Yes, at least at first. The other problem here is that open ranges are computationally intense for Google Sheets algorithms. As you add more and more rows, especially if you have multiple open range ARRAYFORMULA columns, the sheet calculations get slower and slower and slower. The sheet I was working on that prompted this had 21 columns, 8 of which had ARRAYFORMULA formulas in row 2. At around 200 rows of data (not that much in the world of spreadsheets) it was taking MINUTES to calculate with each and every change I was making. That's simply not useable - I almost went back to copying the formula to each row. (It's possible using named ranges may improve the speed some - I didn't try it on that sheet)
So this solution doesn't really work for big (but not even that big) spreadsheets where you have lots of formulas.
Also, a more minor gripe - you'll notice in the example that every row on the spreadsheet was now populated in column D, even where no data was entered. That's annoying, but not a sheet killer by any means - and you could add an IF statement to the ARRAYFORMULA to just output "" whenever you have no data in one or more data columns.
Pros:
Relatively simple and straight forward formula to implement
"Works" with any number of rows
Automatically includes any rows that are added - on the end or in between
Can manage with named ranges
Cons:
Cannot reference data from previous rows
Extremely slow - computation time goes up with every added row (& every added column with an open reference)
Data below ARRAYFORMULA looks like just number entries and could easily confuse people into thinking it's not a formula entry and overwrite it without thinking.
EXAMPLE: HYBRID ARRAYFORMULA
Are you ready to give up on Google Sheets yet?
Well, there is one more option. It gets complicated and involved, but IMO works better in most situations than any of the above examples.
What I do here is add a cell with a formula for the number of rows in the sheet that have data in a certain column. Let's just say column A for this example. That formula looks like this:
= ARRAYFORMULA( MAX( IF( LEN($A:$A), ROW($A:$A), ) ) )
This, in and of itself, is an open ranged formula. It scans everything in column A and returns the last row that has SOMETHING in it. But it's one single formula in one cell reporting 1 value - no other cells get populated from it. It's relatively computationally intense for this one cell, but it's just one cell in the entire sheet.
Then, to make sure that any changes you make (adding / removing rows or columns) do not affect any references to that cell, name it. In the example provided, this is named last_example_row.
I also strongly recommend that you add protection to last_example_row so it's not accidentally changed. Extra tip: you can actually set both sets of permissions: "Only You can edit" and "show a warning when editing" so even if you try to edit it accidentally it will give you the chance to cancel the edit.
Since it's not a piece of data you need visually, hiding it is also a good idea (I left it unhid in the example so you can easily see the formula)
Now, in order to use the value in last_example_row as part of our ranges, we have to use the INDIRECT function. We replace every open-ended instance in the previous example with a specific INDIRECT call.
For calls to the same row, for example, we replace with a pattern like this:
$B$2:$B is replaced with $B$2:INDIRECT( "$B$" & last_example_row )
so it ends on the last used row.
For calls to the previous row, we replace with a pattern like this:
$A$1:$A is replaced with $A$1:INDIRECT( "$B$" & ( last_example_row - 1 ) )
so it ends 1 row before the last used row.
So the final equation becomes this monstrosity:
=ARRAYFORMULA( IF( ISNUMBER( $A$1:INDIRECT( "$A$" & ( last_example_row - 1 ) ) ), $A$1:INDIRECT( "$A$" & ( last_example_row - 1 ) ), 0 ) + $B2:INDIRECT( "$B$" & last_example_row ) * $C2:INDIRECT( "$C$" & last_example_row ) )
So it's a closed range reference that points to a single open range calculation, and it works. Whether you add data in the middle or to the end, it automatically calculates your column for you - and it only populates rows where your data is also populated.
Since it only does the open range calculation ONCE, then uses that value in all remaining closed range calculations, this is much, much faster than the open range example above. It IS slower calculating than the first two examples, however - but I haven't yet hit the point in my real sheets where the delay has made it unusable (stay tuned as I add more data to my sheets over time). If anyone reading this has hit that point with this method, please let me know how many columns & rows you got to, including how many of the columns used an ARRAYFORMULA like this.
Unfortunately, however, since this method requires an INDIRECT call, you cannot use named ranges to accomplish this.
Pros:
Most flexible option
"Works" with any number of rows
Automatically includes any rows that are added - on the end or in between
Much Faster than completely open references
Cons:
Formulas are complex, hard-to-follow, and easy to make a mistake while entering
Slower than closed references - computation still time goes up with every added row and every added column with these "hybrid" references
Data below ARRAYFORMULA looks like just number entries and could easily confuse people into thinking it's not a formula entry and overwrite it without thinking.
Cannot manage with named ranges
Epilogue
Maybe (hopefully) someday Google will add a feature that will keep track of your formulas and execute them in a speedy way and this post will be obsolete. Until then, I hope this post helps someone out there.
Additional Note
Using any of the ARRAYFORMULA methods above can break sorting. If you add filters, and the sort by A->Z or Z->A on a particular column and row 2 is no longer row 2 - then your ARRAYFORMULA gets moved to whatever row it gets sorted to - and then only applies from that row down. Rows above it will be blank in all your ARRAYFORMULA columns. This is very disappointing to me. One way around it (that I don't like) is you can make row 2 a "dummy" row where whatever columns you may sort by have values that will always make it the top row. That's a pretty ugly solution, though.
You can make it less "ugly" by hiding row 2. Then columns will sort fine and you won't see any of the dummy data ("dummy" data may not even be necessary as the hidden row shouldn't sort with the rest). The caveat here is if you share it with multiple users - they won't even see there is a formula being used, it looks like all manual entries - and if one gets overwritten, it will break the ARRAYFORMULA. So, I would recommended protecting the ARRAYFORMULA columns, as well.
I'm practising MS Excel skills. I have a workbook in which I want to analyses data from different tables.
Each worksheet contains a table with the information from the year. So in worksheet "2017" I have a table named "Table2017". I have this for each year (starting 2015).
After a some research, I finally found a way to count how many times something in a certain place happened.
=SUM(COUNTIFS(Table2018[Place];B3;Table2018[Activity];{"Paid";"Awarded"}))
+SUM(COUNTIFS(Table2017[Place];B3;Table2017[Activity];{"Paid";"Awarded"}))
+SUM(COUNTIFS(Table2016[Place];B3;Table2016[Activity];{"Paid";"Awarded"}))
+SUM(COUNTIFS(Table2015[Place];B3;Table2015[Activity];{"Paid";"Awarded"}))
This works perfectly. It will calculate how many times per place a paid service or an awarded (gifted/sponsored) service was delivered. In the B column, I have a list of places (hence the B3 reference), so after completing the formula, I can select the cell and enlarge/drag to copy it to the rest of the column and apply for every place.
However, the formula is really long and every year upon creating a new worksheet, I need to add a new part to the formula.
Is there a way to compact this? And ideally have the formula search for every table that has the relevant information (like: "Table20??" or "Table 20*"), go in and count the times my conditions are found?
I hope my question is clear enough.
Thanks in advance!
P.S. I have zero experience in VBA/VBS, so I'm hoping to realize this in a normal formula.
There are ways to make it more compact, but they will necessarily make the function more complicated, so it wont be any easy win. See for yourself:
you basically need to be able to cycle through the years inside formula without creating custom formulas. One way to do this is to use ROW inside INDIRECT function. This way you can replace multiple
Table2015[Place]
with one array function containing
INDIRECT("Table"&ROW($A$2015:$A$2018)&"[Place]")
as it is an array function it will essentially cycle through the cells in the ROW function creating Table2015[Place], Table2016[Place], Table2017[Place] and Table2018[Place]. Your whole formula would look something like this
=SUM(COUNTIFS(INDIRECT("Table"&ROW($A$2015:$A$2018)&"[Place]");B3;INDIRECT("Table"&ROW($A$2015:$A$2018)&"[Activity]");{"Paid";"Awarded"}))
and it must be entered using ctrl+shift+enter (you will see {} brackets around the function). This should work to make the function smaller and you will need only to change the cell reference each year instead of adding another sum, but the question is if the separate sums are not easier to read and maintain.
I'm working on data from a population of people with allergies. Each person has a unique ExceptionID, and each allergen has a unique AllergenID (451 in total).
I have a data table with 2 columns (ExceptionID and AllergenID), where each person's allergies are listed row by row. This means that the ExceptionID column has repeated values for people with multiple allergies, and the AllergenID column has repeated values for the different people who have that allergy.
I am trying to count how many times each pair of allergies is present in this population (e.g. Allergen#107 & Allergen#108, Allergen#107 & Allergen#109,etc). To keep it simple I've created a matrix of 451 rows X 451 columns, representing every pair (twice actually because A/B and B/A are equivalent).
I somehow need to use the row name (allergenID) to lookup the ExceptionID in my data table, and count the cases where that matches the ExceptionIDs from the column name (also AllergenID). I have no problem using Vlookup or Index/Match, but I'm struggling with the correct combination of a lookup and Sumproduct or Countif formula.
Any help is greatly appreciated!
Mike
PS I'm using Excel 2016 if that changes anything.
-=UPDATE=-
So the methods suggested by Dirk and MacroMarc both worked, though I couldn't apply the latter to my full data set (17,000+ rows) because it was taking a long time.
I've since decided to turn this into a VBA macro because we now want to see the counts of triplets instead of pairs.
With the 2 columns you start with, it is as good as impossible... You would need to check every ExceptionID to have 2 different specific AllergenID. Better use a helper-table with ExceptionID as rows and AllergenID as columns (or the opposite... whatever you like). The helper table needs a formula like:
=COUNTIFS($A:$A,$D2,$B:$B,E$1)
Which then can be auto-filled. (The ranges are from my example, you need to change them to your needs).
With this helper-matrix you can easily go for your bigger matrix like this:
=COUNTIFS(E:E,1,INDEX($E:$G,,MATCH($I2,$E$1:$G$1,0)),1)
Again, you can auto-fill with this formula, but you need to change it, so it fits your needs.
Because the columns have the same ID2 (would be your AllergenID), there is no need to lookup them because E:E changes automatically with the auto-fill.
Most important part of the formulas are the $ which should not be messed up, or you can not auto-fill it.
Picture of my self-made example (formulas are from the upper left cell in each table):
If you still have any questions, just ask :)
It can be done straight from your original set-up with array formulas:
Please note that array formulas MUST be entered with Ctrl-Shift-Enter, before copying across and down:
In the example pic, I have NAMED the data ranges $A$2:$A$21 as 'People' and $B$2:$B$21 as 'Allergens' to make it a nicer set-up. You can see in the formula bar how that looks as a formula. However you could use the standard references like this in your first matrix cell:
EDIT: silly me, N function is not needed to turn the booleans into 1's and 0's, since multiplying booleans will do the trick. Below formula works...
SUM(IF(MATCH($A$2:$A$21,$A$2:$A$21,0)=ROW($A$2:$A$21)-1, NOT(ISERROR(MATCH($A$2:$A$21&$E2,$A$2:$A$21&$B$2:$B$21,0)))*NOT(ISERROR(MATCH($A$2:$A$21&F$1, $A$2:$A$21&$B$2:$B$21,0))), 0))
Then copy from F2 across and down. It can be perhaps improved in technique with sumproduct or whatever, but it's just a rough example of the technique....
I'm using Excel 2010 and have a datasheet with multiple tabs, this is the current SUMIF function that I am using
=IF(SUMIF('Master Data'!$J$2:$J$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,Current_row_different column, "")
Basically, I find some rows in the other sheet that have a value of 1 I then want to use these rows that have a value of 1 but use a different column within that row to populate the true condition.
So say for instance row 4 contains a 1 at column A I then want to stay on row 4 but get the value of column B for the true condition.
Is this possible?
EDIT:
I have now managed to get the function working however its a bit of an Excel hack, because I have had to move the columns around in the master data and its a bit messy now anyway here's what I've got
=IF(SUMIF('Master Data'!$C$2:$C$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,VLOOKUP(B22,'Master Data'!$C$2:$F$90,3,FALSE),"")
Now I know this is because VLOOKUP searches through the first column specified and it doesn't seem to work at all if i try to put the range in backwards i.e. $F$90:$C$2 instead of $C$2:$F$90. Is there any way to manipulate VLOOKUP to work like this?
Yes, actually there is a way - a brother of VLOOKUP - it's INDEX(MATCH()). It is a very useful tool, as you can look at any column and return any other, not only looking at the first one to return the ones to the right. Also, INDEX(MATCH()) can be used in forming array formulas, if you need that, while VLOOKUP cannot.
Basically, this part of your formula:
VLOOKUP(B22,'Master Data'!$C$2:$F$90,3,FALSE)
would be changed with this:
INDEX('Master Data'!$E$2:$E$90,MATCH(B22,'Master Data'!$C$2:$C$90,FALSE))
So, after all, the equivalent for
=IF(SUMIF('Master Data'!$C$2:$C$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,VLOOKUP(B22,'Master Data'!$C$2:$F$90,3,FALSE),"")
would be
=IF(SUMIF('Master Data'!$C$2:$C$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,INDEX('Master Data'!$E$2:$E$90,MATCH(B22,'Master Data'!$C$2:$C$90,FALSE)),"")
i have a little problem with final formulas in one of my column. How to start. maybe i will explain what i have a then what i want.
i have an excel worksheet with 3 sheets. i want to record goods and what are these goods made of. first is sheet called Goods where is possible to put number of goods i want to make. In this case i want to make 1x sandwich1 and at the same time 3x sandwich2. i dont want make sandwich3 this time.
Second sheet is Matrix sheet where I record every good and what it is made of. This sheet is basic sheet and all other sheets take list of goods (resp. ingredients) from this sheet. Simply when i want to make sandwich1 i look at matrix and know that i need 1x1pc of egg + 1x5g of cheese. And for 3x sandwiche2 i need 3x10g of sausages.
Final sheet is called Ingredients. It is a list of used ingredients from Matrix sheet (exactly same order) to make these sandwiches. I want to fill formulas into column B which would go through one ingredient ofter ingredient and count needed amount of it. So it would look into matrix in the same row and where there is some number it would multiply with number of items from Goods sheet. The list of goods is also in the same order as in the matrix sheet.
I hope you understand now what i want and will try to help me. I think there will be SUMPRODUCT, SUMIF and maybe INDERECT functions but i am not that skilled in excel
thanks for any suggestions
You can use MMULT function here - it's an "array formula" which you need to enter in a range. You can do that like this:
In Ingredients worksheet enter this formula in B2
=MMULT(Matrix!C2:E4+0;Goods!B2:B4+0)
[I'm assuming you have a European version of Excel where ; is used to separate arguments]
Now select the whole range B2:B4, press F2 key to select formula and hold down CTRL and SHIFT keys and press ENTER. This "array enters" the formula in the range and you should now see curly braces like { and } around the formula and also the correct results.
You cannot change part of that array now, only the whole thing
Note that I'm assuming that the contents of Goods!A2:A4 will be the same as Matrix!C1:E1 and in the same order. You can extend the ranges to be as large as you like as long as that principle still holds
I suspect that this is an issue of "when all you have is a hammer, every problem is a nail". For reasons known only to you you are using a spreadsheet to solve a problem that databases were made to do. Any solution to this problem in a spreadsheet will be entirely dependent on the integrity of your data - add another column or get things out of order and it will fail.
That said, what you have in your link is effectively a pivot table and what you need is the unpivoted version of this - the instructions for getting this are here.
When you have that, you can use the various database functions in excel to get your answer.