Which of the following Excel formulas performs a calculation only when cell A1…
2023
Which of the following Excel formulas performs a calculation only when cell A1 contains a value-type entry, and otherwise returns 0?
- A.
=IF(CELL("contents",A1)="v",A12,0)
- B.
=IF(CELL("format",A1)="v",A12,0)
- C.
=IF(CELL("type",A1)="v",A12,0)
- D.
=IF(CELL("address",A1)="v",A12,0)
- E.
=IF(CELL("col",A1)="v",A1*2,0)
Attempted by 7 students.
Show answer & explanation
Correct answer: C
Concept
Excel's CELL function returns information about a cell depending on its first argument, the info_type. With the info_type "type", CELL reports the kind of data in the cell as a single-letter code: "v" for a value (a non-text, non-blank entry such as a number), "l" for a label (text), and "b" for a blank cell. Wrapping this code in IF lets the formula return its result only for the chosen data type.
Applying it here
The goal is to produce a result only when A1 holds a value-type (non-text) entry, and to return 0 otherwise.
The test
CELL("type",A1)="v"is TRUE exactly when A1 contains a value, so IF returns its TRUE branch (A12); for text or a blank cell the type code is"l"or"b", the test is FALSE, and IF returns 0.=IF(CELL("type",A1)="v",A12,0)therefore yields its result only for a value-type entry and returns 0 in every other case — exactly the required behaviour.
Why the other info_type codes fail
CELL("contents",A1)returns the actual contents (value or text) of A1, not a type code, so it does not test the data type at all.CELL("format",A1)returns a number-format code (such as"G"or"C2") describing how the cell is displayed, not the value-type flag.CELL("address",A1)returns the reference as text, e.g."$A$1", which describes location, not data type.CELL("col",A1)returns the column number (here 1), again unrelated to data type, so the comparison never yields the value flag.