XERROR.TYPE displays the XTYPE-style error type or error name for all Excel errors
XERROR.TYPE takes three parameters, one requires, and two optional, as follows:
A) The first parameter, required, specifies the input and can be a single cell, range, or array.
B) The second parameter, optional, specifies the type of output data and takes one of three arguments:
0 or omitted, for numeric error-type output
1, for text (descriptive) output
2, for numeric error-number output, same as Excel's built-in ERROR.TYPE
C) The third parameter, optional, specifies what output to display for function entries that are not errors and can take a single entry of any data type (i.e. number, text, blank, logical, or error). If omitted, an #N/A error will be displayed by default
XERROR.TYPE
The following helper functions are also used in the code. Full code and descriptions are included in my "Blank power workbook" template, which you can download through the link in my signature below:
IO (shortened form of ISOMITTED)
PLS (limits parameter to only a single entry)
PO0 (Returns 0 if the parameter is omitted and the parameter itself otherwise)
ISNOTARRAY (Returns TRUE if the reference is not an array [i.e. is a single element or is omitted] and FALSE otherwise)
XERROR.TYPE takes three parameters, one requires, and two optional, as follows:
A) The first parameter, required, specifies the input and can be a single cell, range, or array.
B) The second parameter, optional, specifies the type of output data and takes one of three arguments:
0 or omitted, for numeric error-type output
1, for text (descriptive) output
2, for numeric error-number output, same as Excel's built-in ERROR.TYPE
C) The third parameter, optional, specifies what output to display for function entries that are not errors and can take a single entry of any data type (i.e. number, text, blank, logical, or error). If omitted, an #N/A error will be displayed by default
XERROR.TYPE
VBA Code:
=LAMBDA(reference,[analysis_type],[if_not_error],
IF(IO(reference),
NA(),
LET(
a,PLS(PO0(analysis_type)),
o,SWITCH(a,
0,SWITCH(ERROR.TYPE(reference),0,160,1,161,2,162,3,163,4,164,5,165,6,166,7,167,8,168,9,169,10,1610,11,1611,12,1612,13,1613,14,1614),
1,SWITCH(ERROR.TYPE(reference),0,"dt:ERROR_EXTERNAL!",1,"dt:ERROR_NULL!",2,"dt:ERROR_DIV/0!",3,"dt:ERROR_VALUE!",4,"dt:ERROR_REF!",5,"dt:ERROR_NAME?",6,"dt:ERROR_NUM!",7,"dt:ERROR_N/A",8,"dt:ERROR_GETTING_Data",9,"dt:ERROR_SPILL!",10,"dt:ERROR_CONNECT!",11,"dt:ERROR_BLOCKED!",12,"dt:ERROR_UNKNOWN!",13,"dt:ERROR_FIELD!",14,"dt:ERROR_CALC!"),
2,ERROR.TYPE(reference)),
IF(
ISERROR(a),
o,
IF(
ISNOTARRAY(if_not_error),
IF(IO(if_not_error),o,IF(ISERROR(o),if_not_error,o)),
NA()
)
)
)
)
)
The following helper functions are also used in the code. Full code and descriptions are included in my "Blank power workbook" template, which you can download through the link in my signature below:
IO (shortened form of ISOMITTED)
VBA Code:
=LAMBDA(parameter,ISOMITTED(parameter))
PLS (limits parameter to only a single entry)
VBA Code:
=LAMBDA(parameter,JAN(IF(OR(ISARRAY(parameter),ISERRORS(parameter),ISBLANKS(parameter)),NA(),parameter)))
PO0 (Returns 0 if the parameter is omitted and the parameter itself otherwise)
VBA Code:
=LAMBDA([parameter],IF(IO(parameter),0,parameter))
ISNOTARRAY (Returns TRUE if the reference is not an array [i.e. is a single element or is omitted] and FALSE otherwise)
VBA Code:
=LAMBDA([reference],[output],LET(r,IFERROR(reference,""),o,PLSL(output),m,IF(IO(reference),TRUE,IF(RBYC(r)=1,TRUE,FALSE)),JAO(m,o)))
XERROR.TYPE.xlsx | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | |||
1 | ||||||||||||||||
2 | #CALC! | |||||||||||||||
3 | ||||||||||||||||
4 | #N/A | (reference from blank cell) | ||||||||||||||
5 | #VALUE! | (no reference) | ||||||||||||||
6 | if_not_error | |||||||||||||||
7 | reference input from cells individually | reference input from cells as range (for spill output) | not error | |||||||||||||
8 | analysis_type | analysis_type | ||||||||||||||
9 | error type | error | omitted | 0 | 1 | 2 | omitted | 0 | 1 | 2 | 0 | |||||
10 | 0 | #EXTERNAL! | 160 | 160 | dt:ERROR_EXTERNAL! | 0 | 160 | 160 | dt:ERROR_EXTERNAL! | 0 | 160 | |||||
11 | 1 | #NULL! | 161 | 161 | dt:ERROR_NULL! | 1 | 161 | 161 | dt:ERROR_NULL! | 1 | 161 | |||||
12 | 2 | #DIV/0! | 162 | 162 | dt:ERROR_DIV/0! | 2 | 162 | 162 | dt:ERROR_DIV/0! | 2 | 162 | |||||
13 | 3 | #VALUE! | 163 | 163 | dt:ERROR_VALUE! | 3 | 163 | 163 | dt:ERROR_VALUE! | 3 | 163 | |||||
14 | 4 | #REF! | 164 | 164 | dt:ERROR_REF! | 4 | 164 | 164 | dt:ERROR_REF! | 4 | 164 | |||||
15 | 5 | #NAME? | 165 | 165 | dt:ERROR_NAME? | 5 | 165 | 165 | dt:ERROR_NAME? | 5 | 165 | |||||
16 | 6 | #NUM! | 166 | 166 | dt:ERROR_NUM! | 6 | 166 | 166 | dt:ERROR_NUM! | 6 | 166 | |||||
17 | 7 | #N/A | 167 | 167 | dt:ERROR_N/A | 7 | 167 | 167 | dt:ERROR_N/A | 7 | 167 | |||||
18 | 8 | #GETTING_DATA | 168 | 168 | dt:ERROR_GETTING_Data | 8 | 168 | 168 | dt:ERROR_GETTING_Data | 8 | 168 | |||||
19 | 13 | #FIELD! | 1613 | 1613 | dt:ERROR_FIELD! | 13 | 1613 | 1613 | dt:ERROR_FIELD! | 13 | 1613 | |||||
20 | 14 | #CALC! | 1614 | 1614 | dt:ERROR_CALC! | 14 | 1614 | 1614 | dt:ERROR_CALC! | 14 | 1614 | |||||
21 | n/a | 43 | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | not error | |||||
22 | n/a | book | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | not error | |||||
23 | n/a | TRUE | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | not error | |||||
24 | n/a | FALSE | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | not error | |||||
25 | n/a | "" | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | #N/A | not error | |||||
26 | ||||||||||||||||
27 | if_not_error | |||||||||||||||
28 | reference input directly individually | not error | ||||||||||||||
29 | analysis_type | |||||||||||||||
30 | error type | error | omitted | 0 | 1 | 2 | 0 | |||||||||
31 | 0 | #EXTERNAL! | 160 | 160 | dt:ERROR_EXTERNAL! | 0 | 160 | |||||||||
32 | 1 | #NULL! | 161 | 161 | dt:ERROR_NULL! | 1 | 161 | |||||||||
33 | 2 | #DIV/0! | 162 | 162 | dt:ERROR_DIV/0! | 2 | 162 | |||||||||
34 | 3 | #VALUE! | 163 | 163 | dt:ERROR_VALUE! | 3 | 163 | |||||||||
35 | 4 | #REF! | 164 | 164 | dt:ERROR_REF! | 4 | 164 | |||||||||
36 | 5 | #NAME? | 165 | 165 | dt:ERROR_NAME? | 5 | 165 | |||||||||
37 | 6 | #NUM! | 166 | 166 | dt:ERROR_NUM! | 6 | 166 | |||||||||
38 | 7 | #N/A | 167 | 167 | dt:ERROR_N/A | 7 | 167 | |||||||||
39 | 8 | #GETTING_DATA | 168 | 168 | dt:ERROR_GETTING_Data | 8 | 168 | |||||||||
40 | n/a | 43 | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
41 | n/a | book | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
42 | n/a | book (wihout quotes) | 165 | 165 | dt:ERROR_NAME? | 5 | 165 | |||||||||
43 | n/a | TRUE | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
44 | n/a | FALSE | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
45 | n/a | "" | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
46 | ||||||||||||||||
47 | if_not_error | |||||||||||||||
48 | reference input directly as array (for spill output) | not error | ||||||||||||||
49 | analysis_type | |||||||||||||||
50 | error type | error | omitted | 0 | 1 | 2 | 0 | |||||||||
51 | 0 | #EXTERNAL! | 160 | 160 | dt:ERROR_EXTERNAL! | 0 | 160 | |||||||||
52 | 1 | #NULL! | 161 | 161 | dt:ERROR_NULL! | 1 | 161 | |||||||||
53 | 2 | #DIV/0! | 162 | 162 | dt:ERROR_DIV/0! | 2 | 162 | |||||||||
54 | 3 | #VALUE! | 163 | 163 | dt:ERROR_VALUE! | 3 | 163 | |||||||||
55 | 4 | #REF! | 164 | 164 | dt:ERROR_REF! | 4 | 164 | |||||||||
56 | 5 | #NAME? | 165 | 165 | dt:ERROR_NAME? | 5 | 165 | |||||||||
57 | 6 | #NUM! | 166 | 166 | dt:ERROR_NUM! | 6 | 166 | |||||||||
58 | 7 | #N/A | 167 | 167 | dt:ERROR_N/A | 7 | 167 | |||||||||
59 | 8 | #GETTING_DATA | 168 | 168 | dt:ERROR_GETTING_Data | 8 | 168 | |||||||||
60 | n/a | 43 | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
61 | n/a | book | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
62 | n/a | TRUE | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
63 | n/a | FALSE | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
64 | n/a | "" | #N/A | #N/A | #N/A | #N/A | not error | |||||||||
65 | ||||||||||||||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2 | B2 | =LAMBDA(reference,[analysis_type],[if_not_error],IF(IO(reference),NA(),LET(a,PLS(PO0(analysis_type)),o,SWITCH(a,0,SWITCH(ERROR.TYPE(reference),0,160,1,161,2,162,3,163,4,164,5,165,6,166,7,167,8,168,9,169,10,1610,11,1611,12,1612,13,1613,14,1614),1,SWITCH(ERROR.TYPE(reference),0,"dt:ERROR_EXTERNAL!",1,"dt:ERROR_NULL!",2,"dt:ERROR_DIV/0!",3,"dt:ERROR_VALUE!",4,"dt:ERROR_REF!",5,"dt:ERROR_NAME?",6,"dt:ERROR_NUM!",7,"dt:ERROR_N/A",8,"dt:ERROR_GETTING_Data",9,"dt:ERROR_SPILL!",10,"dt:ERROR_CONNECT!",11,"dt:ERROR_BLOCKED!",12,"dt:ERROR_UNKNOWN!",13,"dt:ERROR_FIELD!",14,"dt:ERROR_CALC!"),2,ERROR.TYPE(reference)),IF(ISERROR(a),o,IF(ISNOTARRAY(if_not_error),IF(IO(if_not_error),o,IF(ISERROR(o),if_not_error,o)),NA()))))) |
C4,D10:D25 | C4 | =XERROR.TYPE(B4) |
C5 | C5 | =XERROR.TYPE() |
E10:E25 | E10 | =XERROR.TYPE(C10,0) |
F10:F25 | F10 | =XERROR.TYPE(C10,1) |
G10:G25 | G10 | =XERROR.TYPE(C10,2) |
H10:H25 | H10 | =XERROR.TYPE(C10:C25) |
I10:I25 | I10 | =XERROR.TYPE(C10:C25,0) |
J10:J25 | J10 | =XERROR.TYPE(C10:C25,1) |
K10:K25 | K10 | =XERROR.TYPE(C10:C25,2) |
C10:C20,C51:C59,C31:C39 | C10 | =XERROR(B10) |
M10 | M10 | =XERROR.TYPE(C10,0,M7) |
M11 | M11 | =XERROR.TYPE(C11,0,M7) |
M12 | M12 | =XERROR.TYPE(C12,0,M7) |
M13 | M13 | =XERROR.TYPE(C13,0,M7) |
M14 | M14 | =XERROR.TYPE(C14,0,M7) |
M15 | M15 | =XERROR.TYPE(C15,0,M7) |
M16 | M16 | =XERROR.TYPE(C16,0,M7) |
M17 | M17 | =XERROR.TYPE(C17,0,M7) |
M18 | M18 | =XERROR.TYPE(C18,0,M7) |
M19 | M19 | =XERROR.TYPE(C19,0,M7) |
M20 | M20 | =XERROR.TYPE(C20,0,M7) |
M21 | M21 | =XERROR.TYPE(C21,0,M7) |
M22 | M22 | =XERROR.TYPE(C22,0,M7) |
M23 | M23 | =XERROR.TYPE(C23,0,M7) |
M24 | M24 | =XERROR.TYPE(C24,0,M7) |
M25 | M25 | =XERROR.TYPE(C25,0,M7) |
D31 | D31 | =XERROR.TYPE(#EXTERNAL!) |
E31 | E31 | =XERROR.TYPE(#EXTERNAL!,0) |
F31 | F31 | =XERROR.TYPE(#EXTERNAL!,1) |
G31 | G31 | =XERROR.TYPE(#EXTERNAL!,2) |
D32 | D32 | =XERROR.TYPE(#NULL!) |
E32 | E32 | =XERROR.TYPE(#NULL!,0) |
F32 | F32 | =XERROR.TYPE(#NULL!,1) |
G32 | G32 | =XERROR.TYPE(#NULL!,2) |
D33 | D33 | =XERROR.TYPE(#DIV/0!) |
E33 | E33 | =XERROR.TYPE(#DIV/0!,0) |
F33 | F33 | =XERROR.TYPE(#DIV/0!,1) |
G33 | G33 | =XERROR.TYPE(#DIV/0!,2) |
D34 | D34 | =XERROR.TYPE(#VALUE!) |
E34 | E34 | =XERROR.TYPE(#VALUE!,0) |
F34 | F34 | =XERROR.TYPE(#VALUE!,1) |
G34 | G34 | =XERROR.TYPE(#VALUE!,2) |
D35 | D35 | =XERROR.TYPE(#REF!) |
E35 | E35 | =XERROR.TYPE(#REF!,0) |
F35 | F35 | =XERROR.TYPE(#REF!,1) |
G35 | G35 | =XERROR.TYPE(#REF!,2) |
D36 | D36 | =XERROR.TYPE(#NAME?) |
E36 | E36 | =XERROR.TYPE(#NAME?,0) |
F36 | F36 | =XERROR.TYPE(#NAME?,1) |
G36 | G36 | =XERROR.TYPE(#NAME?,2) |
D37 | D37 | =XERROR.TYPE(#NUM!) |
E37 | E37 | =XERROR.TYPE(#NUM!,0) |
F37 | F37 | =XERROR.TYPE(#NUM!,1) |
G37 | G37 | =XERROR.TYPE(#NUM!,2) |
D38 | D38 | =XERROR.TYPE(#N/A) |
E38 | E38 | =XERROR.TYPE(#N/A,0) |
F38 | F38 | =XERROR.TYPE(#N/A,1) |
G38 | G38 | =XERROR.TYPE(#N/A,2) |
D39 | D39 | =XERROR.TYPE(#GETTING_DATA) |
E39 | E39 | =XERROR.TYPE(#GETTING_DATA,0) |
F39 | F39 | =XERROR.TYPE(#GETTING_DATA,1) |
G39 | G39 | =XERROR.TYPE(#GETTING_DATA,2) |
D40 | D40 | =XERROR.TYPE(43) |
E40 | E40 | =XERROR.TYPE(43,0) |
F40 | F40 | =XERROR.TYPE(43,1) |
G40 | G40 | =XERROR.TYPE(43,2) |
D41 | D41 | =XERROR.TYPE("book") |
E41 | E41 | =XERROR.TYPE("book",0) |
F41 | F41 | =XERROR.TYPE("book",1) |
G41 | G41 | =XERROR.TYPE("book",2) |
D42 | D42 | =XERROR.TYPE(book) |
E42 | E42 | =XERROR.TYPE(book,0) |
F42 | F42 | =XERROR.TYPE(book,1) |
G42 | G42 | =XERROR.TYPE(book,2) |
D43 | D43 | =XERROR.TYPE(TRUE) |
E43 | E43 | =XERROR.TYPE(TRUE,0) |
F43 | F43 | =XERROR.TYPE(TRUE,1) |
G43 | G43 | =XERROR.TYPE(TRUE,2) |
D44 | D44 | =XERROR.TYPE(FALSE) |
E44 | E44 | =XERROR.TYPE(FALSE,0) |
F44 | F44 | =XERROR.TYPE(FALSE,1) |
G44 | G44 | =XERROR.TYPE(FALSE,2) |
D45 | D45 | =XERROR.TYPE("") |
E45 | E45 | =XERROR.TYPE("",0) |
F45 | F45 | =XERROR.TYPE("",1) |
G45 | G45 | =XERROR.TYPE("",2) |
I31 | I31 | =XERROR.TYPE(#EXTERNAL!,0,I28) |
I32 | I32 | =XERROR.TYPE(#NULL!,0,I28) |
I33 | I33 | =XERROR.TYPE(#DIV/0!,0,I28) |
I34 | I34 | =XERROR.TYPE(#VALUE!,0,I28) |
I35 | I35 | =XERROR.TYPE(#REF!,0,I28) |
I36 | I36 | =XERROR.TYPE(#NAME?,0,I28) |
I37 | I37 | =XERROR.TYPE(#NUM!,0,I28) |
I38 | I38 | =XERROR.TYPE(#N/A,0,I28) |
I39 | I39 | =XERROR.TYPE(#GETTING_DATA,0,I28) |
I40 | I40 | =XERROR.TYPE(43,0,I28) |
I41 | I41 | =XERROR.TYPE("book",0,I28) |
I42 | I42 | =XERROR.TYPE(book,0,I28) |
I43 | I43 | =XERROR.TYPE(TRUE,0,I28) |
I44 | I44 | =XERROR.TYPE(FALSE,0,I28) |
I45 | I45 | =XERROR.TYPE("",0,I28) |
D51:D64 | D51 | =XERROR.TYPE({#EXTERNAL!;#NULL!;#DIV/0!;#VALUE!;#REF!;#NAME?;#NUM!;#N/A;#GETTING_DATA;43;"book";TRUE;FALSE;""}) |
E51:E64 | E51 | =XERROR.TYPE({#EXTERNAL!;#NULL!;#DIV/0!;#VALUE!;#REF!;#NAME?;#NUM!;#N/A;#GETTING_DATA;43;"book";TRUE;FALSE;""},0) |
F51:F64 | F51 | =XERROR.TYPE({#EXTERNAL!;#NULL!;#DIV/0!;#VALUE!;#REF!;#NAME?;#NUM!;#N/A;#GETTING_DATA;43;"book";TRUE;FALSE;""},1) |
G51:G64 | G51 | =XERROR.TYPE({#EXTERNAL!;#NULL!;#DIV/0!;#VALUE!;#REF!;#NAME?;#NUM!;#N/A;#GETTING_DATA;43;"book";TRUE;FALSE;""},2) |
I51:I64 | I51 | =XERROR.TYPE({#EXTERNAL!;#NULL!;#DIV/0!;#VALUE!;#REF!;#NAME?;#NUM!;#N/A;#GETTING_DATA;43;"book";TRUE;FALSE;""},0,I48) |
Dynamic array formulas. |
Upvote
0