I have a spreadsheet where I want cell formula to always look at a specific cell, even if rows or columns are inserted and the specific cell moves. Effectively, I always want to look at the 'top' cell of a table, even if new rows are inserted at the top of the table.
eg. Cell A2 has the formula[=$E$2]
Now I highlight row 1 and do Insert Row. The formula in A2 now says [=$E$3] but I want it to be looking at the new row 2.
The dollars will keep an absolute cell reference no matter what I do to the 'referencing' cell, but I want the cell reference to be absolute no matter what I do to the 'referenced' cell. If that makes sense!
Effectively, I have a 'table' in excel 2007 and I want to always reference the top row. The trouble is that rows are added to this table from the top so the top row keeps moving down to make room for a new top row.
--- Alistair.
Try =indirect("F2"). This will work if you know that the top-right cell of the table is always going to be $F$2.
You could also use the Offset Function:
http://office.microsoft.com/en-us/excel-help/offset-function-HP010342739.aspx
or
https://support.office.com/en-us/article/offset-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66
Building on #ktdrv's answer (I can't comment): =indirect("F"&ROW()) would be $F2 if it's a reference that needs to be dragged down multiple rows. A minor drawback with =indirect() is that you lose cell reference highlighting for the formula.
Related
I'm using Index-Match to match Full Names with head count in that party.
I have it working but it uses both the structured and explicit cell reference.
I can't figure out why when I add a new row in my table, the column with the index-match formula wont populate the last row.
This is the formula used:
=IFNA(INDEX(AA:AA,MATCH([#[Preferred Seating 1st Choice]],D:D,0)),"")
Column AA has the head count number and column D has the list of full names.
Preferred Seating is the column used to reference the search.
I looked around and can't seem to find why it wont fill in the last row after that rown info is entered.
I can only assume it has something to do with the mixed Explicit-structured cell/column references. Any help please.
Yes Excel may not automatically assume a formula needs to be automatically filled in an entire table column if it contains unusual references. Unless you have data outside the table, you should just refer to the columns in the table:
=IFNA(INDEX([Column AA Name],MATCH([#[Preferred Seating 1st Choice]],[Column D Name],0)),"")
These can be easily entered when editing the formula by selecting all cells in the source columns excluding the heading. The formula will always use the entire
source columns and the formula should automatically fill its own entire column.
You can also control whether a column automatically has its formula updated through a hidden property. The ability to change the behavior of the column only appears through the front end when you're making changes to the column.
After entering a formula in a column, Excel will either automatically fill the entire column and give you the option to turn off the automatic fill, or Excel will not automatically fill the entire column and give you the option to turn it on.
After entering a formula that isn't being filled, this icon will appear:
Click it and then select to Overwrite all cells in this column with this formula
Deleting a formula from one cell in a column that is being automatically filled will turn off the automatic fill. Double clicking a cell with a formula and pressing enter will give you the option to turn it on again.
I have created several hyperlinks in a column, which links to another spreadsheet of the same workbook. Over there all the cell references are also in a column. Now i want to insert a row on the second page on the top of the sheet. As I do that the cell reference doesn't change and the previous cell figures drops down. How can i update multiple cell reference automatically as I insert row on top of the second sheet?
I am not sure of your specific situation but this is how I interpreted what you wrote:
If this is off, let me know.
With that said, ensure that you aren't using absolute cell references in your first sheet.
Absolute cell references are denoted with a $ in font of either the column, row, or both.
Here is a reference from MS on Absolute, Relative, and Mixed cell references: https://support.office.com/en-us/article/Switch-between-relative-absolute-and-mixed-references-dfec08cd-ae65-4f56-839e-5f0d8d0baca9
I am attempting to use an IF statement to check whether the sum of two cells from another Excel sheet is greater than or equal to 1.
For a sheet called Test1 with the values of interest in column C, this is what I have so far, which works fine:
=IF((Test1!C1+Test1!C2>=1),1,0)
In column B on a second sheet that I'll call Test2, I want to copy this formula down 200,000 rows. However, if the aforementioned formula is in cell B1, for the formula in B2 I would like the formula to read:
=IF((Test1!C3+Test1!C4>=1),1,0)
I want to copy the formula down the column so that the second cell reference in the formula in the first row does not become the first cell reference in the formula in the second row (eg. it would go C1+C2, then C3+C4, C5+C6, etc.).
I have tried manually entering the formula for a few rows, highlighting those, and copying them down but can't get the desired cell reference pattern. If I highlight and drag these first three formulae down another three rows, C4 and C5 are repeated and not in the correct pair.
=IF((Test1!C1+Test1!C2>=1),1,0)
=IF((Test1!C3+Test1!C4>=1),1,0)
=IF((Test1!C5+Test1!C6>=1),1,0)
=IF((Test1!C4+Test1!C5>=1),1,0)
=IF((Test1!C6+Test1!C7>=1),1,0)
=IF((Test1!C8+Test1!C9>=1),1,0)
I have tried using OFFSET() within this formula but couldn't get it to work. I am basically just wanting to add 1 to each of the cell references in the formula, as compared to the previous row (but not to actually add 1 to the value of that cell, as would happen with C1+1 for example).
Any insight would be greatly appreciated!
If you plan on copying this down 200K rows then you will want the absolute simplest formula that accomplishes the stagger. Avoid the volatile OFFSET function or be prepared to spend a lot of time waiting for random calculation cycles to complete. A volatile function will recalculate whenever anything in the workbook changes; not just when something changes that involved the formula in the cell.
=--(SUM(INDEX(Test1!C:C, (ROW(1:1)-1)*2+1), INDEX(Test1!C:C, (ROW(1:1)-1)*2+2))>=1)
The following formula should do the trick:
=(SUM(INDIRECT("C"&ROW()*2-1);INDIRECT("C"&ROW()*2))>=1)*1
And that's the version using IF:
=IF(SUM(INDIRECT("C"&ZEILE()*2-1);INDIRECT("C"&ROW()*2))>=1;1;0)
You say I am basically just wanting to add '1' to each of the cell references in the formula but appear to be incrementing by 2, so I am confused but an option might be to apply you existing formula to 400,000 rows, together with =ISODD(ROW()) in another column, then filter on that other column to select and delete those showing FALSE.
Excel's autofill won't do the 2-cell shift that you're looking for. You can use the functionality that is there.
Put =IF((Test1!C1+Test1!C2>=1),1,0) in the top cell and drag a copy to the second row (it will be =IF((Test1!C2+Test1!C3>=1),1,0) but that's okay). Now, put 'A' and 'B' in the next column. Select all 4 cells and copy them down 400k rows.
Use filter to delete rows flagged with 'B' and delete the blank rows.
(Select blank rows with [F5] click Special and select Blanks, then right-click and delete)
Here is all you need. It's fast and nonvolatile.
=--(SUM(INDEX(Test1!C:C,ROW(1:1)*2-2):INDEX(Test1!C:C,ROW(2:2)*2-2))>=1)
Copy it down as far as you like.
I have two pre-filled spreadsheets ('main data' and 'variable prices') and VBA code that formats and copies one row from 'main data' to a 'results' sheet using some values from 'variable prices'.
On the first sheet a certain value is calculated using a cell in, say, BR column, when row is copied to the 'results' sheet that value is moved to another column, BY.
Something terrible happened and now the formula that calculates total on the 'results' is not updated and takes irrelevant value from BR column.
How to manually (I am guessing that when I put this together half a year ago the reference was updated automatically, but got destroyed when my boss edited/copied values or whole rows of data from other files, deleting the files after - I get "broken link" message now) set it back?
I hope this is legible. This is my only VBA experience, its operation is still somewhat of a mystery..
Thank you!
When you copy data as a formula and you want to keep referencing parts to the originating column/cell, you can "lock" the references. Example in a cell:
=A1, when copied two columns to the right would result in =C1 or
=A1, when copied tow rows down would result in =A3.
You can fix/anchor either the column, or the row or both in a formula by putting a $ in from of the reference. =$A1 remains =$A1 even when copied two columns to the right. =A$1, remains =A$1, even when copied two rows down. =$A$1 will always stay =$A$1, wherever you copy this to.
Alternatively, if you only want the value (not the formula), use paste.value or
cells(ref.target).value = cells(ref.org).value.
Oh forgot to tell you, when you highlight a cell address (A1) and you press F4, you can toggle between 4 stages from $A$1, $A1, A$1, A1
I'd like to apply some conditional formatting where each cell of a row is compared to the cell in the previous row. If it differs then the row is highlighted.
I'm using Excel 2007. Is this even possible? If so could someone provide me with the steps to apply this to an entire table of data?
Yes, it is possible. It was possible in previous versions of Excel, too.
The condition is very simple.
Select the data, starting from the second row of data (the third row counting from the header), bring up the condition formatting dialog, select "Formula" and enter =A3<>A2, =A3<>OFFSET(A3,-1,0) where A3 is the top-left cell of the selection.
Note the absence of dollar signs - Excel will automatically suggest them, so delete accordingly.
Because the reference is not absolute, the formatting will properly apply to the whole table.
You can make it even more versatile, like this:
=INDIRECT(ADDRESS(ROW(), COLUMN()))<>INDIRECT(ADDRESS(ROW()-1, COLUMN()))
Here's how it works:
=ADDRESS(ROW(), COLUMN()) refers to the current cell (i.e. the one to be formatted).
Similarly, =ADDRESS(ROW()-1, COLUMN()) refers to the cell above the current cell. Then all I do is compare the two.