问题
I have this formula here:
=IFERROR(IF(D4<=0,0+(VLOOKUP(A4,'Civil Maintenance'!A5:C46,3,FALSE)),_
C4+(VLOOKUP(A4,'Civil Maintenance'!A5:C46,3,FALSE))),"0")
As you all know when you drag it down to copy the formula to other cells in the column, it adds one to all the references (D4 becomes D5 etc.) However i was wondering if there's a way to stop this for certain parts? I want to keep the lookup search area the same so that A5:C46 stays the same in all formulas of the column but i still want the D4, A4 ... to match the row it's in.
Manually changing all the cell references is very time consuming and I was hoping to save a bit of time as there is plenty of rows!
回答1:
What you are after is called relative/absolute cell referencing. In Excel, a $ sign locks the row or column.
=A1 dragged down becomes =A2 and dragged to the right becomes =B1 This is a relative cell reference.
=$A1 dragged down becomes =$A2 and dragged to the right stays =$A1 because the column is locked with the $ sign. The column reference is absolute and the row reference is relative.
=A$1 dragged down stays =A$1 because the row number is locked, dragged to the right it becomes =B$1 . The column reference is relative and the row reference is absolute.
And, finally =$A$1 can be dragged in any direction and will stay =$A$1, because both row and column are locked with the $ sign. This is an absolute reference.
Does that make it clearer?
Without the context of your data and what the formula is supposed to do, it's hard to tell which references in your formula should be locked for rows, columns, both, or neither, but with the info above you should be able to work that out.
来源:https://stackoverflow.com/questions/52145920/keeping-cell-references-the-same-when-applying-formula-to-entire-column