I'm trying to program my Excel document to help me calculate weekly costs of products I buy, on a shifting database. So far I made three sheets within the document.
Sheet1 has input data
Sheet2 processes Sheet1 data values
Sheet3 spits out a weekly income.
I am able to reference the cells ='Sheet1'!C2 in Sheet2.
What I want to do is reference a static column (i.e. Sheet1 insert new column 'C', making old 'C' to 'D') without breaking my function.
I've tried ='Sheet1'!$C3' but the moment I shift the column in Sheet1, Sheet2 does not keep the function 'Sheet1'!$C3.
Instead it translates to 'Sheet1'!$D3
Of course I can simply just fix my Sheet2 reference cell each time (changing from 'Sheet1'!D3 to !C3) with a new column in Sheet1 but if I don't have to keep fixing the function that would be fantastic.
How do I keep my reference cell from changing referenced column?
(I don't need to use $D$3 because I have a vertical line of cells I need to read.)
You can reference the cell using R:C format so for ='Sheet1'!$C3 you can change it to ='Sheet1'!$3:3. The idea is you use the : to separate the columns and the rows. you then convert the column portion to its corresponding number value such as A=1, B=2 C=3...
Related
I have a table in excel which is constantly having new rows added. I then have another sheet (lets call it results) which is referencing this table, and counting the values in each column.
Every time I add a new record/row to my table, the results sheet throws a bunch of errors in every cell that references the column. Because I'm using a fixed range in the formula to count the column, e.g. =SUM(A1:A10), I then need to manually click each cell in results and select 'include adjacent cells' to get the count to reflect the new data. I have loads of cells in this table and I'm adding data daily so this is a very long winded way of doing things.
I'm looking for a way that I can automatically update these cells, either by using a macro, or adjusting the formula so that it will automatically increase the range of the SUM when I add new data.
The best solution I've had so far was to simply define the range to include the row below my last piece of data (i.e. if A10 is my last record, the formula would be =SUM(A1:A11)). This works, and auto increments the formula when a new cell is added. However, if I delete the record from the table for any reason, the formula reverts to only including the range containing data.
In other words, this solution works, but only until I have to delete a record. Is there any better solution that can detect which rows are populated, and auto include them in the formula?
=SUMPRODUCT(INDEX('Sheet1!'A:A,1):INDEX('Sheet1!'A:A,LOOKUP(2,1/('Sheet1!'A:A<>""),ROW('Sheet1!'A:A))))
Using INDEX and ROW reference, deleting cells won't result in broken cell references. LOOKUP is used to calculate the last non-empty cell in column A. This will auto update.
Using SUMPRODUCT instead of SUM makes it an array formula and does not require older Excel versions to enter the formula with ctrl+shift+enter (because of the LOOKUP function)
In Office 365 you could use: =SUM(FILTER('Sheet1!'A:A,'Sheet1!'A:A<>""))
In my worksheet in column F I have a list of names, that may appear or disappear according to other inputs in the spreadsheet. I want the cells in the columns G:AZ to remain blank if the corresponding cell (i.e. same row) in column F is also blank. Because I have thousands of cells to which I need to apply this, I'm using Pullover's Macro Creator to add this small change to all the formulas inside the cells really quickly, so I can do entire columns in seconds. In column J, for example, I've been applying this formula:
=IF(COUNTBLANK(INDIRECT("RC[-4]",0))=1,"",[this part changes and doesn't matter])
You can see that I need to change that "-4" to different numbers according to the column I'm working on. But I have so many columns that it's still going to be a pain to change that hundreds of times.
My question: Is there a formula I can use in the COUNTBLANK function that can reference the corresponding cell in column F without needing any changes in different columns and different rows? And since the INDIRECT formula is so volatile (I still don't know what that means, but I guess it's bad), is there a solution that doesn't use this formula?
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 data that comes in into a sheet in certain time intervals, but every time the order might be different. So now, I want to "copy" the values from the "unsorted" sheet, to a new sheet which is sorted in the order I would like the data to be. From here on, calculations can be done using fixed references when referring to the "sorted" sheet.
Here is what I've done so far:
Determine the location of the label of the needed subset of the data in the unsorted sheet.
Determine where the actual needed data is on the sheet (the label is above the data, and one column to the right, so the data is one row down and one column to the left, and goes on for 32 columns and down 24 rows).
Now I want to do this step:
Use a array formula (CSE function) to reference those cells, as seen in this screenshot:
Trying to copy using CSE reference
Hitting Ctrl+Shift+Enter shows the result: #REF
What can I do differently?
Based on the feedback by #tigeravatar:
I referenced the range to the ASTIR sheet incorrectly:
in cell K13 is an invalid reference of "ASTIR!$A$5:ASTIR!$AF$29". You
don't need the sheet name twice, which is what's causing the #REF!
error.
SHORT QUESTION
Ive got a formula =IF(ISBLANK(Q.1!C71),"",Q.1!C71) im trying to be able to set a control cell / variable so instead of C71 it would reference c*$B$1*, *$B$1* being my reference / control cell / variable in the same sheet as this formula, any ideas how to do this ?
LONG QUESTION
Ive got a spreadsheet that is regularly provided by a 3rd part with different data in it each time, although the column order of the data is always the same.
To get the data into my spreadsheet, i create another tab in the same workbook as their sheet and reference the data in their spreadsheet in a sheet i call import template sheet, i then from there copy and paste the import sheet into my spreadsheet, as all the columns match.
To reorder their columns in a non destructive way i use the following formula in my import template sheet, for instance if i wanted their column C, in my sheets column F i would place this in F1 and the pull the cell down so it does this for all rows :
=IF(ISBLANK(Q.1!C71),"",Q.1!C71) (the ifblank just helps sanitise the data by not throwing #ref if there is no data in the cell.)
The issue i have is that i have around 30 columns to re order and although the column structure is the same, there is sometimes some 'header' data (basically a text summary) at the top of the document of varying length, so instead of the first row i need being 71 sometimes it might be row 50 or row 90...
To speed things up id like to be able to have a control number / variable cell where i can set a variable for the starting row, and then reference that in my cell, so that i dont have the go and edit the formula in 30 different columns.
If you want to control the starting row of the reference by putting a number in cell B1, that would look something like this:
B1
71
Referencing Cell
=IF(ISBLANK(INDIRECT("Q.1!C"&B1),"",INDIRECT("Q.1!C"&B1))
INDIRECT allows you to build a string representation of a cell reference and then get the value of that cell. So we build a string reference using the value of B1, and then use INDIRECT to get the value of that string's referenced cell.