I have an Excel document that I need to have a totals sheet which takes in a specific cell over multiple sheets. It also needs to be expandable so I can just add the sheet name to a row or something and it will add it into the formula and the total.
Just a row like this or something similar which could be used to add more sheets in future.
To give you an example currently, I am using a simple SUM function but it's not easily expandable:
=SUM('Sheet1'!A6,'Sheet2'!A6,'Sheet3'!A6)
I have had a look at INDIRECT but I can't find a way of having it expand to the length of an array eg. something like this:
=SUM(INDIRECT(H3:H8,"!A6"))
Would return all the values of A6 across each sheet named in H3:H8 evaluating like:
=SUM(INDIRECT(H3,"!A6"),INDIRECT(H4,"!A6"),INDIRECT(H5,"!A6")...)
If anyone has any ideas of what I can use to achieve this, it would be very helpful!
If you want a dynamic list of sheets for your sum formula, you may
Put the names of the sheets across which you would like to sum your cell(s) on a separate range of cells organized as a column range:
Sheet1
Sheet2
...
Convert the cells with the names of sheets into a table (select your range, then on the main menu panel select "Insert - Table").
Name the created table list (i.e. "List_of_Sheets")
To sum use the formula:
=SUMPRODUCT(SUM(INDIRECT("'"&List_of_Sheets&"'!A6")))
You may change the names of sheets in your table or add the new ones at the end of the table
Try this,
SUM(Sheet1:Sheet3!A6)
You can add a Sheet named „Start“ and one named „End“.
Place all sheets you want to sum between the both. So you can use
SUM(Start:End!A6)
Related
Can someone help me write VBA function to get data from another worksheet using multiple filter?
Data looks something like this.
I want to write a function that extract the A1 or A2 or A3 value based on the dropdown I select. If I select A3 it should pick data from A3 column. My Filter criteria on other columns are Item, id and location. Column for Item, id and location are static. While column for A1, A2, A3 are dynamic. I want to put criteria on Ite, id and location. These are the three criteria and result should be from the fourth column. i.e. either A1 or A2 or A3 based on what I select.
I tried but couldn't figure out. Can someone help me on this, please?
You don't need VBA for this but you do need to make a few preparations. I will show here what I did. There are other ways and you can choose the way you prefer.
I created a table exactly as you posted. Instead of a table you can just create a named range or you can replace the names of either in the formulas with the range's coordinates. I didn't name the table but recommend that you do if you use a table. In my example the table's name is Table1.
Within the table I created a named range comprising the cells D1:F1. I called this range "Data" but any other name will do as well. You may also move the named range entirely elsewhere if you want different captions for the columns for one reason or another. As you will see, the names are insignificant they are used to create the numbers 1, 2 and 3 from the location where they are within the named range Data.
Now I created a validation drop-down referring to a List of =Data. The effect is that I have a drop-down with A1, A2 and A3 in it. I created this drop-down in A10 of a different sheet from the one on which I have Table1.
Now I used the following formulas to extract data from row 2 of the table.
=INDEX(Table1[Item],2)
=INDEX(Table1[Location],2) or =INDEX(Table1,2,3) and
=INDEX(Table1,2,3+MATCH(A10,Data,0))
Observe that every "2" in the above formulas refers to the 2nd row in the named range Table1. I didn't set up a range of that name but that is something Excel threw in when I created the table. However, you would like to pull data from other rows as well.
For that purpose you can use the ROW() function. This function returns the number of the row in which it resides. If it's in row 10 it will return 10, in row 11 it returns 11 etc. It's a counter. Therefore, if you entered my formulas in row 10 you can replace all the "2"s with Row()-8 and as you copy up or down you will get data from different rows, same columns.
=INDEX(Table1[Item],Row()-8)
=INDEX(Table1[Location],Row()-8) or =INDEX(Table1,Row()-8,3) and
=INDEX(Table1,Row()-8,3+MATCH(A10,Data,0))
If your first formula isn't in row 10 you must adjust the number to be deducted according to where your formula was entered.
I am trying to create a SUMIF function that dynamically adds up values in a specific column of a named range in my Excel sheet.
It is very easy to do this when there is no named range :
The formula picks out all the cells that contain "London" in their name and sums up the expenses related to London.
What I am trying to do is to use a named range called TripsData (A2:B5) and tell the SUMIF function to sum the entries in the column 2 of this range that meet the criterion of having London in their name.
How can I make this work without needing to create a second named range for column 2 and simply by telling Excel to look within the specified column of this named range? Index/Match only return one value so that doesn't work when there are several cells with London in their name.
Thanks for your help!
Use INDEX to refer to a specific column in the named range (it can refer to a whole column), like this
=SUMIF(TripsData,"*London*",INDEX(TripsData,,2))
You can do that without any named ranges at all, if you turn your data into an Excel Table object. Select any cell in the range or the whole range and click Insert > Table or hit Ctrl-T.
There will be a dialog that asks if your table has headers. Yours does. Now you can reference the table and its columns by their inherent names and build your formula like this:
=SUMIF(Table1[Expense],"*London*",Table1[Cost])
You can rename the table, of course, even after the formula is in place. When you click a cell in the table, there will be a new ribbon for commands that relate to tables only. It's a very powerful tool.
Any formulas, formatting etc. that apply to a whole table column will automatically carry over into new table rows. The table column reference will adjust automatically, too, of course, so you don't have to mess with dynamic range names or re-define what a named range applies to.
Note: the formula uses structured referencing instead of cell addresses. This option can be turned off by clicking File > Options > Formulas > tick or untick "Use table names in formulas"
You can use Chris' idea of Index(Table1,,Col#) with the named range "Table1" (without creating an Excel table Object if you don't want to for some reason) and STILL avoid the problem Applez mentions in the comment below Chris' idea. Applez warns that using a constant for a column number reference is dangerous if you later insert another column before that column in the named range. You will find that Excel does NOT auto increment the constant, so your formula breaks.
Applez is right..... so DON'T use a constant, use a column number "reference" instead of a constant. For example....
=SUMIF(TripsData,"*London*",INDEX(TripsData,,Column(B1)))
If you later insert a column between A and B, Excel WILL auto increment the reference Column(B1) to Column(C1). Just don't delete B1 or Row 1 or you will get a REF error. I usually use the the header/tile "cell" (in whatever row that is in) for that table column within the Column reference (as it is highly unlikely I will ever delete the header/title cell of column of a table unless I delete the entire column). In this particular example as it turn out, B1 "IS" the the title/header cell for that column in the data table. So that is what I used for the example.
Awesome formula, just in case anyone needs to use a similar approach to FILTER a range. I used this approach
pmGendHC is the range I wanted to filter (I expect a spilled range with my data) I needed a colum (column number 13) to be different than 0
=FILTER(pmGendHC,INDEX(pmGendHC,,13)<>0)
I have a workbook with 11 sheets for each month, and one summary sheet.
On each sheet is a list of website in column A between A2 and A13, and in column B are some values taken from those website.
The individual Month sheets look something like this:
HOWEVER, it is possible that the information may be in a different order, so I have had to use MATCH to find the row where I want to get the data from.
The summary sheet looks something like this:
I want to build a formula that will sum all the values across the 11 worksheets for each website.
I tried to use INDEX and MATCH like this:
=INDEX(January!$A$2:$B$12,MATCH($A3,January!$A$2:$A$13,0),2)
Now this works for January and copies down for all the web-sites ok, but I'd like to SUM all the worksheets without adding the formulas?
How can I do something like this across all the worksheets?
It seems a bit naff to just add a plus sign and write eleven formulas in each cell
Create a named range (eg) SHEETS containing your sheet names (in a column)
In B3 on your summary sheet:
=SUMPRODUCT(SUMIF(INDIRECT(SHEETS & "!A2:A11"), A3, INDIRECT(SHEETS & "!B2:B11")))
and fill down
i have a specific problem to solve. I dont know how to do it but want to do it without macro or worse without VB script.
I will explain what i have and then what i want to do.
I have (plan to have) many sheets in worksheet. first sheet is some intro sheet, where i have also one column containing name of sheets in every cell. i am using formula "=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)" so i can change name of sheet and it will change also name of sheet in intro sheet cell.
so for imagination i have column N and there i have sheet1, under that sheet2 and so on...
Each of sheets have the same construction and same formulas on the same place, so i have each sheet for every goods.
And now what i would like to have. I want to add a formula into intro sheet where i would summarize SUM (add) or something like that. It would take every value form each sheet on the same place on each sheet. so the formula would look something like this: "=sheet1!C4 + sheet2!C4 + sheet3!C4 + .... + 'any sheet'!C4" but i dont know how many sheets i will have and the number will sometimes change and i dont want to edit formula because i plan to have more this kind of dynamic formulas.
i will just add another sheet into column N and every formula using this excel type for cycle would take and recount formula using this dynamic array. i hope you understand what i want. my problem is much more complicated but when i describe it more into detials you would loose the point of my interest.
thanks for any suggestions
edit: but if there is only a solution using VBA script, i will have to use it. i dont want to change formula everytime i add another sheet into worksheet
What you describe is a 3D formula. You can do something like
=SUM(Sheet1:Sheet4!A1)
Excel will sum cell A1 in all sheets from Sheet1 to Sheet4 and any sheets that are between these two. You can insert new sheets and they don't have to be named SheetX.
In order to manage the 3D formulas more efficiently, you could use two sheets like bookends before and after the sheets you want to include in the formula: Insert two sheets called "First" and "Last" and ensure that all sheets you want to sum are arranged between these two sheets. Then on your intro sheet use
=SUM(First:Last!A1)
You can hide the "First" and "Last" sheets and only unhide them when you need to check your sheet arrangements for your formulas.
You can insert new sheets and make sure that they are located between your bookend sheets. Drag sheets in and out between the bookends to include or exclude them from the 3D formula.
I have two worksheets; Sheet1 contains different building names (repetition) and Sheet2 contains a list of the building names. I will like to count the number of building in sheet1 and show them in sheet2.
Currently, I'm using workbook function COUNTIF. How can i do it if there's a new building added in sheet1? (VBA or workbook function is fine)
You could create a dynamic named range in sheet 1 (for the list of buildings), and then refer to the named range in your countif function in sheet2.
For more details on how dynamic named ranges work, have a look at this:-
http://www.ozgrid.com/Excel/DynamicRanges.htm
Another alternative would be to use the whole column that contains the building names, as your countif function will only return a value for cells that contain the criteria specified in the function. It might look something like this:-
=countif(Sheet1!A:A,"building a") <--this would search for all cells containing 'building a' in column A of Sheet 1
As you use either dynamic range or A:A range on CounIF() it works only as long as you do not have any blank cells within the range. Please know that. In such cases you are better off with a pivot table and pointing to pivot table's total cells accordingly.
Or if you still prefer to use CountIf() in blank cells case, you may apply conditional formatting to fill the blanks with some text/string. Don't forget conditional formatting contributes to slowing down your sheet performance. Or you could wrap CountIf() with an IF condition.