Equal a fixed reference - reference

I wish to create a fixed reference text that will not change dynamically. The reference should not change when I add an extra row, as it usually does. Say, a cell A1 has this content:
=E5
and thus takes the value of cell E5. If I add a new row so the referenced cell is E6, the value of my cell A1 also changes to:
=E6
Is it possible to type in a reference to a cell that will never change dynamically but will remain E5 e.g. no matter how I do cell rearranging?
I namely have a sheet of posts whereto I often add new rows. The topmost post should always be shown in another cell.

For what you describe I think:
=offset(A1,5,4)
would serve (though the more usual requirement is probably "the other way around" - ie keep a cell referenced to a value whose location may change, such as a totals row when further data is added).
offset

Related

How to insert the value of another cell in excel not the formula

I have an excel sheet that changes regularly. I want to add a number of offset formulas that reference a particular cell as a starting point, however this first cell moves up or down the page. eg the starting point is A20 one week, but next week it is at A33 etc. I need to reference this cell further down the sheet.
So further down (in say cell B302) I would enter =Offset(A20, 0, 0) to get the start cell, then below that (B303) =Offset(A20,1,0), then below that =Offset(A20,2,0) etc etc etc
But if A20 changes all the time, how do I tell each offset formula where to start without changing every single one? I thought about writing "A20" in cell B301, then instead of using "A20" in Offset, I would equal the 'value' of B301 (eg A20). That way I just need to change the value of B301 each week instead of all the offset formulas. Is there a way to insert the string value of a cell, not the formula? eg =Offset(B301,1,0) - where B301 equals A20, or A33 etc etc?
I can think of 2 options for this :
1st - You can use Find & replace to change the Reference Cell.
2nd - You can write down the Reference cell number in a Cell and use indirect in all of the Functions Offset to use that cell as reference. So you can change the value in that reference cell and the formulas will get updated automatically.
Create a name (eg) "REFCELL" and point it to A20.
Then you can use
=OFFSET(REFCELL,1,0) etc.
Later you can update the name to point to your new location.

How to 'lock' a cell reference so it doesn't change when sorted/filtered?

I have a formula that relies on the values in other specific cells to work correctly, yet have found out that when I sort my worksheet randomly these references are replaced with relative references, or absolute ones if I use $ in the cell numbers. I have tried to 'name' the cells but naming them doesn't make a difference. Is there a way to uniquely identify a cell so I can find it no matter if the sheet is sorted or changed?
If I understand correctly, you want the selected range to stay the same regardless of the cell the formula is run from.
This is called absolute cell reference.
To do this, put dollar signs in front of the row or column you want to stay the same. In your example, using COUNTIF($M$100:$M$105) will select the range M100:M105, even when you copy that formula to a different cell.

Why won't my spreadsheet equations stay the same after i add a new row

I am making a spreadsheet which has multiple sheets and one of the sheets has an equation that looks to see if there is anything written in a certain cell on all the other sheets. Right now I just use this equation to find out whether or not it has anything written in that cell.
=IF(LEN('A'!N18)>1,CONCATENATE('A'!C18," "),)
This is just checking to see if anything is in the cell. The problem is that I want this to keep working if I add a new row on A, but right now it bumps row 18 to 19 and I am left with no row 18 so it won't even check that new row!
If you want to add a row between row 1 and row 18 on worksheet A but keep your formula references to A!N18 and A!C18 then you need to use INDIRECT or INDEX. Of these two, INDEX is the better choice as it is not volatile. A volatile function like INDIRECT will recalculate whenever anything in the workbook chanmges. A non-volatile function like INDEX will only recalculate when something that affects its outcome is changed.
'INDIRECT method; works but not optimal
=IF(LEN(INDIRECT("'A'!N18"))>1,CONCATENATE(INDIRECT("'A'!C18"," "),)
'INDEX method; works and is non-volatile
=IF(LEN(INDEX('A'!N:N, 18))>1,CONCATENATE(INDEX('A'!C:C, 18)," "),)
The link that Slai posted in the comments to your question should be what you're looking for. If you don't want a reference to change when you add/delete rows/columns you need to use absolute references. As currently written "N18" and "C18" are relative references. If you change the columns/rows on sheet 'A', these references will automatically change with them. That's why it's moving to row 19 on you.
You can turn these into absolute references by adding "$" like this: "$C$18" and "$N$18". The first "$" sets the absolute reference for the column and the second sets the absolute reference for the row. You can mix and match these for various results.
Mixing relative and absolute values really comes in handy when you are reusing a formula with slight differences. For instance, if you want to multiply a number in column b (starting with row 4) by the number in A1 and show the result in column C (also starting with row 4). You'll always be using A1 so we can set this as an absolute value and in C4 enter the formula =$A$1*B4. Copy this down column C and it will automatically update the B value to the new column but will always use "$A$1" for the other part.
You can split the relative reference by only using the "$" on the column or row reference of the reference. Whichever one you use it on will be locked and the other can still adjust based on changes to the sheet or copying. Learning how to use absolute references can be a great time-saver.
I'm curious about part of your formula though. Why are you concatenating C18 with just a blank space? If you are using the info somewhere else, it may make sense to add the space in that concatenate but it's a personal choice.

Use formula to dynamically modify named range

I am using a bunch of named ranges in a workbook. Here is the history of how it has changed to make it more dynamic for when they ask me to modify it.
What I want to do is search the A column from 1 to 100 for the label in the A column (that I code into the named range formula) and where it finds it, the named range will know is the row. I know I will still need to update the named range if we ever change the name of a row but I would only need to update one named range as opposed to 75-100 named ranges as I do now whenever we make a change.
Here is the current Named Range that I am using:
=INDIRECT("Input!$C$23:"LastColumn&"$23")
LastColumn is a named range that contains the letter of the last column.
Here is some history on why I do it this way:
When I first created it I referenced the cells directly in formulas (no named range) and had to change all the formulas whenever I added another row, column, etc. Then I switched it to Named References. This fixed it so whenever we added a row, I did not need to change the references at all. However, I still had to change all the references whenever we changed the amount of columns. What I did was make the columns variable, so if we change the amount of columns I don't have to make any changes to the named ranges. Unfortunately, this had the unintended consequences of making it so whenever I add, remove, or move a row I need to update all the references. Now, I have an idea that will make both the rows and the columns variable. So, I can make any change without having to update any references.
I needed to do it this way because most of the time the columns will be empty and I do not know when they will have data in them.
Abandon the volatile INDIRECT function and use the INDEX function for the termination of the range with MATCH locating the last column. The row can be determined by a MATCH on column A to "Label".
As I understand it, you want to locate "Label" in column A and have its location define the row in =INDIRECT("Input!$C$23:"LastColumn&"$23") where 23 currently defines the row.
Abandoning INDIRECT, the Input!$C$23 reference can be changed to:
=INDEX(Input!$C:$C, MATCH("Label", Input!$A:$A, 0))
So all that is left is to find the last column. There must be something on that worksheet that can be used to locate the last column regardless of column deletions or additions but I will just use the last value in the row that contains "Label" in column A.
'this finds the last text value in row 23
=MATCH("zzz", Input!23:23)
'this finds the last number or date value in row 23
=MATCH(1e99, Input!23:23)
'since I do not know whether *the row* (e.g. 23:23) contains text, numbers, dates
'or a combination of any of those, I will have to double up the formula and add error control
=MAX(IFERROR(MATCH("zzz", Input!23:23), 0), IFERROR(MATCH(1e99, Input!23:23), 0))
You can stitch two INDEX functions together with a colon just as if you were typing C23:Z23.
=INDEX(Input!$C:$C, MATCH("Label", Input!$A:$A, 0)):INDEX(Input!$A:$ZZ,MATCH("Label",Input!$A:$A,0),MAX(IFERROR(MATCH(1E+99, INDEX(Input!$A:$ZZ,MATCH("Label",Input!$A:$A,0),0)),0),IFERROR(MATCH("zzz",INDEX(Input!$A:$ZZ,MATCH("Label",Input!$A:$A,0),0)),0)))
Yes, it looks complicated but a lot of that comes from not knowing whether the row in question contains text or numbers and it does less work than a volatile INDIRECT (which recalculates whenever anything in the entire workbook changes) while remaining up-to-date despite row and column deletion/insertions.
BTW, when using text-as-cell-references within INDIRECT there is no need to use the $ absolute reference indicator. An address-as-text is a text string; it will not change no matter what you do to it short of retyping it. The above method does require absolute cell referencing as it is using actual cell and cell range references.

Excel Dynamic Ranges changing (with no logic)

A confusing one. I'm using a dynamic range
=OFFSET('EA OPs'!A4,0,0,COUNTA('EA OPs'!$A:$A)-1,96)
I've assigned it to rOps in the NAME MANAGER. I've then tried to change a Pivot Table source to rOps. Click in to a random cell. Click back in the NAME MANAGER and it has changed to:
=OFFSET('EA OPs'!G3,0,0,COUNTA('EA OPs'!$A:$A)-1,96)
then
=OFFSET('EA OPs'!G24,0,0,COUNTA('EA OPs'!$A:$A)-1,96)
seemingly at random. Althought it does seem to keep near to the cell I've clicked on?
Any ideas?
You need to anchor the A4 with dollar signs and make it an absolute reference. Otherwise it's relative to whatever cell is active:
=OFFSET('EA OPs'!$A$4,0,0,COUNTA('EA OPs'!$A:$A)-1,96)
Named ranges always behave this way, which can be useful. For example with A2 active, you can create a range named "CellAbove" and set it to "=A1". You can then use it in a formula in any cell, e.g., `=CellAbove/2' and the result will be the value of the cell one row up, divided by 2.

Resources