Excel is a spreadsheet program. Functions can be used to perform mathematical and logical operations on data from other cells.

In Excel, the address of a cell, consisting of a letter for the column and a number for the row, can be used to retrieve its contents (for instance A1). For example, we want to use another cell value in cell C1. In absolute terms, we query the fixed address A1. Relatively speaking, we are querying the cell of the same row in column A.

When applying the formula to adjacent cells, the relative cell address is used. If this is undesirable, we can freeze the row or column by placing a dollar sign in front of it (for instance $A$1).

Excel tries its best to maintain links to the correct cell when, for example, new columns or rows are created between them or the calculating cells are moved. Since after applying the formula to adjacent cell, each cell calls a different address, it is very difficult to check the correctness of the links. Especially when other people touch the spreadsheet, errors can quickly creep in unnoticed and are not obvious.

Therefore, it is more reliable and error resistant to use the same formula in all cells and to express relative queries explicitly. In the following, we will learn this alternative way to query other cells absolutely or relatively.

Set common names

  • SELECT A1
  • open Name Manager (Ctrl + F3)
  • click New...
  • add the following entries
Name:Scope:Refers to:
THIS_CELLcurrent sheetA1
THIS_ROWcurrent sheetROW(THIS_CELL)
THIS_COLUMN_NUMBERcurrent sheetCOLUMN(THIS_CELL)
THIS_COLUMNcurrent sheetSUBSTITUTE(ADDRESS(THIS_ROW, THIS_COLUMN_NUMBER,4),THIS_ROW,"")
  • repeat for every sheet

Get cell information

DescriptionCommandExample
Get current cellTHIS_CELLC2 0
throws circular reference
Get current rowTHIS_ROWC2 2
Get current columnTHIS_COLUMNC2 C
Get current column numberTHIS_COLUMN_NUMBERC2 3
Get current addressADDRESS(THIS_ROW,THIS_COLUMN_NUMBER)C2 $C$2
Get current addressADDRESS(THIS_ROW,THIS_COLUMN_NUMBER,4)C2 C2

Get neighboring cells

DescriptionCommandExample
Get current cellINDIRECT(THIS_COLUMN & THIS_ROW)
INDIRECT(ADDRESS(THIS_ROW,THIS_COLUMN_NUMBER))
C2 C2
throws circular reference
Get E column in current rowINDIRECT("E" & THIS_ROW)C2 E2
Get 5th row in current columnINDIRECT(THIS_COLUMN & 5)C2 C5
Get right neighborINDIRECT(ADDRESS(THIS_ROW,THIS_COLUMN_NUMBER+1))C2 C3
Get left neighborINDIRECT(ADDRESS(THIS_ROW,THIS_COLUMN_NUMBER-1))C2 C1
Get upper neighborINDIRECT(ADDRESS(THIS_ROW-1,THIS_COLUMN_NUMBER))C2 B2
Get lower neighborINDIRECT(ADDRESS(THIS_ROW+1,THIS_COLUMN_NUMBER))C2 D2

Is a range of cells empty

=IF(SUMPRODUCT(--(D16:G16<>""))<>0,"not empty","empty")

Get last non-empty cell in a given range

=SUM(A4:INDEX(A4:A10,MATCH(TRUE,(A4:A10=""),0)))

Sum column values until next blank cell?

=SUM(A4:INDEX(A4:A10,MATCH(TRUE,(A4:A10=""),0)))

Sources:

Related:

Tags:
Microsoft Excel
Improve workflow in applications