I would like to SUM() to a specific but variable row in excel.
I've tried dynamic ranges but didn't have much luck. I want to be able to insert rows in this range and have sum take account of the newly inserted values.
For example before inserting a new row the formula might look like this:
=SUM(A2:A3)
And after insertion the formula should look like this:
=SUM(A3:A4)
Any ideas?
I solved it by extending my range one row up:
=SUM(A1:A3)
Then, by inserting a row at A2 the range does indeed extend automatically.
Related
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)
I'd like to fill every other row in an excel worksheet with the value that is following that row.
See example.
Is there a way to accomplish this?
I am sorry if this is an extremely easy task, but I just can't get my head around how this may work, since just plain copying the data, filtering for blank rows and pasting it into the filtered table just doesn't work as I want it to.
Thanks in advance.
Edit: It might be worth adding that I cannot at all change rows or columns in the excel sheet since it is connected to a database which configuration does not allow this.
Add a new helper column with the formula =ISEVEN(ROW()).
Filter this column on TRUE.
Select the range from A2 to the bottom-right of the cells that you want to populate, and input =A3 [Ctrl-Enter].
Clear the filter and delete the helper column.
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 worksheet with a large number of tables. Every other table is formatted the same. Each row has set columns that will not change with regard to the formula. Say... =(A * B / G) - D
I'm trying to figure out a way to write a Worksheet formula that I can cut and paste without having to alter the row reference in the formula for it to work. That way I can copy and paste the formula into each table since I cannot click and drag it down the whole worksheet.
Ideally, I'd like to keep a list of formulas in a text file that I could just cut and past and not have to alter. I would be really cool if I could do something similar for using UDFs that can figure out the Range(Cells()) location on its own.
I'm using . Thanks!
=ROW()
but from your description I am not sure why you can not copy something like $A1 down and let the 1 update as it goes down each row. Take a look at what the effect of the $ symbol before the column or cell reference does. It prevents the column letter and/or row number from changing as cells are copied from one location to another.
ROW() will return the row number of what row it is in, or the row number of a reference if you supply the reference address:
ROW(AS134) will return 134.
To use this, you would most likely need to combine it with something like INDIRECT:
=INDIRECT("A"&ROW())
That formula would reference column A and the same row as wherever the formula was placed. HOWEVER, INDIRECT is a bad choice if you are using it frequently as its a volatile function and will recalculate anytime something on the worksheet changes. As per Scott Craner's suggestion, INDEX is a non volatile function so it will not force the recalculations and would look something like:
=INDEX(A:A,ROW())
Looking to create a sum and a count formula that will automatically adjust itself for new rows that are inserted within the range.
For example if I have the formula in cell D55 =SUM(D17:D54). Every time I insert a new row within that range, I need to change the top range of my formula to account for it.
Is there a way to write a formula that will automatically adjust itself, so that every time I add a new row I will not need to change my summation formula?
Try
D55: =SUM(INDIRECT("D17:D"&ROW()-1))
This should dynamically adjust to added rows since when adding rows at row 17 the current value at D17 shifts to D18 and no value is present at D17. INDIRECT() should take this into account. ROW()-1 ensures that even when rows are added immediately preceding the formula these are still taken into account.
Edit: I should have added that this can be applied to any formula. Simply replace the range part of your formula with the INDIRECT.
And a quick explanation: the INDIRECT creates an Excel reference from a string so you can construct your formula using dynamic objects. The ROW part of the formula acts as the dynamic factor which is completely dependent on the row count that you add but is independent of the position at which you add your new row.
I think people are misunderstanding. You're inserting a row at the TOP of your range correct?
If so, I would suggest formatting the range as a table. That way your table could look like this:
And the sum function would be simply:
=SUM([Data])
when a row is inserted above the 7, everything is automatically updated.
You might want to have a look at this excellent link that talks about using tables to hold your ranges. This would be my recommendation ... wrap your data in a table. This will create a structured yet flexible reference.
As is noted here, and also from experience, "Because table data ranges often change, the cell references for structured references adjust automatically. For example, if you use a table name in a formula to count all the data cells in a table, and you then add a row of data, the cell reference automatically adjusts."