My Excel-Workbook contains a number of sheets which each contain simulation data. The first sheet however, will be used to aggregate averages over all simulations. Each sheet contains the data of a single simulation.
Now what I would like to do is to have a single reference in which I can enter the names of all simulation sheets and then use this reference in all other charts / tables to perform things like calculating averages over all the sheets.
What I got so far is this:
=AVERAGE('Simulation 1:Simulation 2:Simulation 3'!C2:C8)
However, I have many of these cells and I frequently add new simulation sheets. Therefore I don't want to maintain every single cell like this. Instead I would like to have a single cell in which I maintain the sheets that are used. I tried this:
'Simulation 1:Simulation 2:Simulation 3'
This cell has the text "'Simulation 1:Simulation 2:Simulation 3'" as plain text. I created a name called "EnabledSheets" on the cell and altered the other cells to:
=AVERAGE(EnabledSheets!D2:D8)
This does not work however. Does anyone know a way to make this work? I really have many sheets and their number changes very frequently...
Thank you!
I would create two bracketting sheets.....alpha and omega and place all your actual data sheets between these.
Then a formula like:
=AVERAGE(alpha:omega!A1)
would require no adjustment as data sheets are added or removed.
Related
Here is simplified EXCEL file I am working on.
Data sheet 1 called "first":
Data sheet 2 called "second":
Data structure and range (C2:E8) is same. I need to sum those sheets based on criteria in column B (Option).
Outcome I expect:
option1_sum sheet:
option2_sum sheet:
I can achieve this by putting either this formula in sum sheet C2 and dragging to E8:
=SUMIF(first!$B2,$B$2,first!C2)+SUMIF(second!$B2,$B$2,second!C2)
or this:
=IF(first!$B2=$B$2,first!C2,0)+IF(second!$B$2=$B2,second!C2,0)
These works as expected. Calculations are fast. The problem is that in original file there are ~100 data sheets to sum and area is more than 30000 cells in each sheet.
Formulas are getting very long and file is getting too heavy, takes ages to open.
If there wouldn't be IF condition I would calculate like this:
=sum(first:second!C2)
I expected SUMIF to work like this:
=SUMIF(first:second!$B2,$B$2,first:second!C2)
Unfortunately it doesn't. Every solution I've found uses INDIRECT formula like this:
=SUMPRODUCT(SUMIF(INDIRECT("'"&Sheetlist&"'!B2"),$B$2,INDIRECT("'"&Sheetlist&"'!C2"))) where Sheetlist is named list:
It does work, it is much shorter and makes file lighter more than 3 times, but because INDIRECT is volatile formula, it freezes excel for 5 seconds every time change is made in data sheets. And changes are made often.
Are there any other ways to make file lighter without losing speed?
Limitations:
Can't use VBA because it is stored in Sharepoint and accessed via both Excel 365 and browser Excel
Can't use manual recalculation as it is constantly monitored by several people and changes need to be seen on the spot
UPDATE: #JvdV suggested formula works, but after adding 10+ sheets every recalculations takes more than 5 seconds.
Updated said formula to include blank cells:
=LET(x,WRAPROWS(TOCOL(first:last!A1:E8,0),5),IFERROR(DROP(REDUCE(0,A2:A8,LAMBDA(a,b,VSTACK(a,BYCOL(FILTER(DROP(x,,2),(TAKE(x,,1)=b)*(INDEX(x,,2)=B2),0),LAMBDA(c,SUM(c)))))),1),0))
Using a custom function from the name manager comes to mind. Something like =TOCOL(GET.WORKBOOK(1)) would spill all sheetnames but it requires to save your workbook as .xlsm. So I came up with another idea. If your sheets are always in order you could do something like:
=WRAPROWS(TOCOL(first:last!A:E,1),5)
Now let's incorporate this into a REDUCE() to fill all cells in each sum-sheet:
Formula in C2:
=LET(x,WRAPROWS(TOCOL(first:last!A:E,1),5),IFERROR(DROP(REDUCE(0,A2:A8,LAMBDA(a,b,VSTACK(a,BYCOL(FILTER(DROP(x,,2),(TAKE(x,,1)=b)*(INDEX(x,,2)=B2),0),LAMBDA(c,SUM(c)))))),1),0))
Note that 'last' is just a placeholder for whatever is the last sheet in the sequence of sheets to sum from. I hope that below visual will help cover the basics of the theory implemented:
I have a workbook containing 8 worksheets which are all of the same format. I have built a formula to calculate the Max value in a particular cell across all the worksheets:
=MAX(MAX('Equipment - A:Equipment - H'!C17))
This works great. It finds me the Max value out of the 8 instances of cell C17.
What I now want to know is which sheet that Max value is found on. I tried to use the MATCH function, but it doesn't seem to work:
=MATCH(MAX('Equipment - A:Equipment - H'!C17),'Equipment - A:Equipment - H'!C17)
returns #N/A.
All my Google searches tend to point to using VLOOKUP but this seems like a bit of a sledgehammer tactic.
Any ideas?
How about this...
I'll psuedo code this since there are too many unknown details, but essentially, as you said each of the sheets is the same format, so you can use Excel Power Query (builtin 2016, add-in to 2010/2013), to open and reformat ONE of the sheets to:
1) INCLUDE the name of the sheet, and;
2) exclude all of the other rows you don't don't need (eg only the max row).
This can be applied as a function call in PQ (see this link) to open AND process all of the other tabs. At the end of each process, the resulting output can be merged to a seperate work table, and when completed will require a vlookup() to that temp/helper sheet/table to return the needed value (remember, I said PQ can incoprorate the sheet name as one of the data attributes from the 'imported' sheet.)
I'm working on a Google Sheets based database for work, which shows availability on the dive boats, which instructors are available etc.
I need to copy some some similar formulas to the rows below. There are 365 rows for each day of the year, and several columns with different formulas I need to copy. Sound's straight-forward enough right, but, there's a couple of things that makes this harder.
Here's one of the formulas...
=IF(AND(COUNTIF(MER!$T4:$T23,AE3)=0,COUNTIF(CHO!$T4:$T23,AE3)=0, COUNTIF(KEP!$T4:$T23,AE3)=0,COUNTIF(SUP!$T4:$T23,AE3)=0),AE3,"")
I am working from Sheet 'AVL'. It basically references ranges in
five different sheets in the same workbook to look for a match
against a list of dive instructors we employ who are available to
work on a daily basis.
I need to copy the formula to the rows directly below, so close to
200 rows for the remainder of this year, and on a new sheet for
2017, a further 365 rows.
If I copy as normal on google sheets, > Paste special > Paste formula, the formula increases the row number on the formula by one row. EG:
=IF(AND(COUNTIF(MER!$T4:$T23,AE3)=0,COUNTIF(CHO!$T4:$T23,AE3)=0, COUNTIF(KEP!$T4:$T23,AE3)=0,COUNTIF(SUP!$T4:$T23,AE3)=0),AE3,"")
=IF(AND(COUNTIF(MER!$T5:$T24,AE4)=0,COUNTIF(CHO!$T5:$T24,AE4)=0, COUNTIF(KEP!$T5:$T24,AE4)=0,COUNTIF(SUP!$T5:$T24,AE4)=0),AE4,"")
That's no good to me, because the ranges I need to reference from the other sheets are completely different, but, the cell referenced with the staff name on, on the sheet I'm working on 'AVL' moves down by one row which is correct.
The ranges from the five other sheets needs to move down by 26 rows each time. EG:
=IF(AND(COUNTIF(MER!$T4:$T23,AE3)=0,COUNTIF(CHO!$T4:$T23,AE3)=0, COUNTIF(KEP!$T4:$T23,AE3)=0,COUNTIF(SUP!$T4:$T23,AE3)=0),AE3,"")
=IF(AND(COUNTIF(MER!$T30:$T49,AE4)=0,COUNTIF(CHO!$T30:$T49,AE4)=0, COUNTIF(KEP!$T30:$T49,AE4)=0, COUNTIF(SUP!$T30:$T49,AE4)=0, COUNTIF(OTH!$T30:$T49,AE4)=0),AE4,"")
=IF(AND(COUNTIF(MER!$U56:$U75,AE5)=0,COUNTIF(CHO!$U56:$U75,AE5)=0, COUNTIF(KEP!$U56:$U75,AE5)=0,COUNTIF(SUP!$U56:$U75,AF5)=0, COUNTIF(OTH!$U56:$U75,AE5)=0),AE5,"")
Etc etc.
I've used the INDIRECT function previously for something else, and was wondering if I should be looking at combining the formula I used for something else, with the formula I need to copy 1,000's of times. EG...
=INDIRECT("CHO!B" & (3 + 26*(ROW()-3)))
adjusted and modified and combined with...
=IF(AND(COUNTIF(MER!$T4:$T23,AE3)=0,COUNTIF(CHO!$T4:$T23,AE3)=0, COUNTIF(KEP!$T4:$T23,AE3)=0,COUNTIF(SUP!$T4:$T23,AE3)=0),AE3,"")
to somehow increase the ranges by 26 rows every time I copy the formula, while leaving the cell I'm matching against AE3 etc, to just increase by one row.
Build your cell ranges with a pair of non-volatile¹ INDEX functions.
For example, these two cell ranges are exactly the same.
=T4:T23
=INDEX(T:T, 4):INDEX(T:T, 23)
The rest is just simple maths and a ROW function. Put this in the top row.
=IF(AND(COUNTIF(INDEX(MER!$T:$T, (ROW(1:1)-1)*26+4):INDEX(MER!$T:$T, (ROW(1:1)-1)*26+23), AE3)=0,
COUNTIF(INDEX(CHO!$T:$T, (ROW(1:1)-1)*26+4):INDEX(CHO!$T:$T, (ROW(1:1)-1)*26+23), AE3)=0,
COUNTIF(INDEX(KEP!$T:$T, (ROW(1:1)-1)*26+4):INDEX(KEP!$T:$T, (ROW(1:1)-1)*26+23), AE3)=0,
COUNTIF(INDEX(SUP!$T:$T, (ROW(1:1)-1)*26+4):INDEX(SUP!$T:$T, (ROW(1:1)-1)*26+23), AE3)=0), AE3, "")
Fill down as necessary.
¹ Volatile functions recalculate whenever anything in the entire workbook changes, not just when something that affects their outcome changes. Examples of volatile functions are INDIRECT, OFFSET, TODAY, NOW, RAND and RANDBETWEEN. Some sub-functions of the CELL and INFO worksheet functions will make them volatile as well.
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.
I'm stuck on an Excel problem and am hoping someone can assist. I read through 10-15 topics that are similar, but I wasn't able to get anything to work. Here is where I'm at...
I have a large data set containing columns for Year, Name, Total 1, Total 2 (and 20+ other columns). The same names appear in multiple rows based on the yearly totals. On a separate sheet, I have another data set containing Name and would like to pull the data from sheet one into columns as shown below.
I have done this in the past using only one year as the initial data set with the following formula:
=INDEX(DATARANGE,MATCH([#Name],DATARANGE[Name],0),MATCH("Total 1",DATARANGE[#Headers],0))
The problem I am having is the result of adding multiple years of data to my 1st data set. Is there a way to match the row based on name and year and then return the results of the appropriate column?
=SUM(($A$2:$A$9=B$16)*($B$2:$B$9=$A17)*($C$2:$C$9))
Enter above in cell B14 as an array formula or below as standard
=SUMPRODUCT(($A$2:$A$9=B$16)*($B$2:$B$9=$A17)*($C$2:$C$9))
You can do the same for total 2 just replace Cs with Ds
And then drag right and down.
Change the first MATCH function to something like this:
=MATCH(1,INDEX(([#Name]=DATARANGE[Name])*([#Year]=DATARANGE[Year]),0),0)
so as part of your whole formula that would be this
=INDEX(DATARANGE,MATCH(1,INDEX(([#Name]=DATARANGE[Name])*([#Year]=DATARANGE[Year]),0),0)
,MATCH("Total 1",DATARANGE[#Headers],0))
Another way you can use for returning numbers only (as here) is like this: (with cell refs for simplicity).
=SUMPRODUCT((A2:A9=2013)*(B2:B9="name x")*(C1:D1="Total 1"),C2:D9)
If the presented data to be indexed is a table then
This
=MATCH(1,INDEX(([#Name]=DATARANGE[Name])*([#Year]=DATARANGE[Year]),0),0)
should be corrected to a proper structured reference of
#[Name]
Also since this is an array formula it may not work with structured references at all. You'd be better served with regular cell references. Also if it is not a table only cell references will work.