返回列表 发布新帖

[教程] Excel任意方向查找、反向查找、多条件查找、自定义默认值--XLOOKUP函数

263 0
打工日常 发表于 2026-1-9 10:09:58 | 查看全部 阅读模式 来自:Error

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
<p><img src="data/attachment/forum/202601/09/100933fsqyo5eiostd99a4.webp" alt="d94295e4de394fb78c498cc0286bf45e.webp" title="xlookup函数-Excel教程-匠们网" /></p>
- ^' @) i2 h  a4 t9 q<p><code>XLOOKUP</code> 是 <strong>Excel 365/2021 及后续版本</strong>新增的<strong>新一代动态查找函数</strong>,专为解决传统查找函数(<code>VLOOKUP</code>/<code>HLOOKUP</code>/<code>INDEX+MATCH</code>)的痛点设计,支持<strong>任意方向查找、反向查找、多条件查找、自定义默认值</strong>等功能,且语法更简洁、逻辑更直观。</p>0 \. e% j2 n! `- k1 ?
<h2>一、函数核心语法与参数说明</h2>4 G2 ?8 }( M6 b9 o# ?3 d' F* C2 q
<h3>1. 完整语法</h3>
  N$ G+ A# Q, Z/ F/ l5 T<pre><code class="language-excel">XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
5 A4 Q6 V% J9 e' n</code></pre>9 v8 e* I# J5 w' R
<h3>2. 参数逐义解析</h3>/ R" m* F) L9 o0 P' V+ X
<table>6 h1 a4 |5 V- `" D/ g2 o' h
<thead>' z0 l- c8 M& e- g7 [8 W" [
<tr>- V+ e( r8 W7 D9 S
<th>参数名</th>2 D+ k5 H0 C9 F! [, o& C" i- P2 O
<th>必选/可选</th>2 ^; n$ X& [6 Z# F7 D. o- c4 F
<th>数据类型</th>
% E7 j6 _' ?% i7 O( b; E3 ?<th>核心作用</th>4 g  @" F) Q. R) k: Z+ F
<th>注意事项</th>- @0 @+ }8 d+ N+ v9 |) _& \0 C
</tr>7 c  F3 N3 {8 k3 B2 P- o. V
</thead>
# x9 Z$ ~( ^' e! y# y3 I<tbody>" m3 t. A4 v8 F+ X& v, Z" f- |5 u
<tr>6 U& b. f. S0 J  s% o1 x+ ^) Q
<td><code>lookup_value</code></td>6 |" h0 Z7 A# N/ a0 b
<td>必选</td>* C( v) z  R2 g
<td>任意类型(文本/数字/单元格引用)</td>
, q" h5 i- [7 B5 `<td><strong>查找目标</strong>:要在 <code>lookup_array</code> 中寻找的值</td>; G$ @. t. J$ [! S
<td>可直接输入常量(如 <code>&quot;张三&quot;</code>/<code>1001</code>),或引用单元格</td>
0 z  @* y6 g$ y/ f# R1 ~8 @</tr>
% c' \( A" x% Z, U' a7 \4 \# g; G<tr>1 e+ s$ O/ W5 W: N4 }
<td><code>lookup_array</code></td>
/ S+ J( a$ \5 N" ~3 M<td>必选</td>4 M9 [% c8 |4 H$ u2 L1 ]
<td>单行/单列区域/一维数组</td>
# v  e" s6 d0 a( y7 S<td><strong>查找区域</strong>:存放查找目标的区域,仅支持<strong>单行或单列</strong></td>
! C2 T5 j) J3 R, r5 j0 S" u; c7 S<td>区域大小必须与 <code>return_array</code> 完全一致(行数/列数相同)</td>
4 r0 H; C! _1 C6 Z3 C! k</tr>3 ~' A/ c! S* C% u4 D: M
<tr>
: D7 r7 ?% w, \, T9 s<td><code>return_array</code></td>+ J1 ^' u( i5 H/ E4 g
<td>必选</td># Y7 H7 S- Z; ?  G3 `' y
<td>单行/单列区域/一维数组</td>
. z( C7 d- c% |3 u- w2 J, R: U<td><strong>返回区域</strong>:找到匹配值后,要返回的结果区域,仅支持<strong>单行或单列</strong></td>8 E+ W! A4 T; `* c$ h- F
<td>与 <code>lookup_array</code> 一一对应,匹配到第 N 个值,就返回 <code>return_array</code> 第 N 个值</td>. B$ s* N, L1 E- o, v2 _! Q1 x7 j- P
</tr>5 }2 I; b" z! o3 f
<tr>
& E+ `  J+ h9 t3 e! `1 `6 W5 K<td><code>[if_not_found]</code></td>+ j2 w' v% I5 U8 q
<td>可选</td>2 T7 V8 @( L, h: o# r
<td>任意类型</td>4 S' v" q" ^. @# U0 I
<td><strong>未找到默认值</strong>:当 <code>lookup_array</code> 中无匹配项时,返回的自定义结果</td>+ c0 V2 T: \( e) N4 q4 K+ V
<td>省略时默认返回 <code>#N/A</code> 错误</td>0 K; p8 i% E6 b, U
</tr>8 k" O8 g' s; E( y. }- N3 r8 g* @
<tr>
3 A' K+ B1 P; U% S<td><code>[match_mode]</code></td>( t" Y7 m4 K' Y$ l) W+ G: ]3 F
<td>可选</td>6 A' {: a- j  t; R* [
<td>数字(0/1/-1/2)</td>) B1 w7 v8 g+ G" o* K& |
<td><strong>匹配模式</strong>:定义查找的匹配规则</td>' T  b( {6 q0 Q- t. V* d' ]7 @
<td>0 = 精确匹配(默认);1 = 近似匹配(升序);-1 = 近似匹配(降序);2 = 通配符匹配</td>
  x( e5 e+ E& ?5 Y/ |: T</tr>
/ [& J! g8 o) e4 g5 ~<tr>
4 S5 F+ j, D4 b) k% B<td><code>[search_mode]</code></td>* @/ D* ^1 j$ x  ~9 F! M2 }( n
<td>可选</td>( R6 C! \; L+ o3 \+ d
<td>数字(1/-1/2/-2)</td>
3 V2 ^! n# c9 Q( |1 a<td><strong>搜索模式</strong>:定义查找的搜索方向和规则</td>( h7 E1 \" o8 n1 p( }0 Z
<td>1 = 从前往后搜索(默认);-1 = 从后往前搜索;2 = 二分法(升序);-2 = 二分法(降序)</td>
3 y7 ~( A6 g6 i& L/ N0 D</tr>
. p' c" A" F2 i# y8 t" Q) C</tbody>; |( u9 V+ {: p0 d# k3 B. a1 W* z
</table>
- y/ A: G4 m- k2 d. \<h3>3. 关键特性</h3>& P- d7 R' c3 ^% L
<ul>
4 L, r) M0 Z4 d<li><strong>方向自由</strong>:无需区分垂直/水平查找,<code>lookup_array</code> 和 <code>return_array</code> 可以是任意单行/单列。</li>
' Z8 V7 q8 [3 {) P4 T<li><strong>反向查找</strong>:无需调整数据源顺序,直接实现“由值找键”(如根据姓名找工号)。</li>5 @2 e9 _6 C% ~  s* k0 h7 @
<li><strong>动态适配</strong>:支持与动态数组函数(<code>FILTER</code>/<code>SORT</code>)嵌套,返回多结果溢出。</li>1 z( }. @8 b, ]6 ~; F
<li><strong>错误友好</strong>:通过 <code>if_not_found</code> 自定义未找到的提示,避免 <code>#N/A</code> 错误。</li>
& a1 J5 p5 P2 R2 c/ s</ul>
4 I& ]  S: U1 l1 O7 f. o<h2>二、数据源准备(通用示例数据)</h2>
4 j6 }- h" j! x* [1 X8 F) f6 E<p>为统一示例,使用<strong>员工信息表</strong>作为基础数据源,共 5 行数据:</p>
0 u- U3 ?- s' B# J. h! _6 M9 U<table>
( {4 h) B8 H4 I<thead>. n& P3 m: X1 q: ~3 U8 g1 \( U
<tr>
: @5 M4 u4 G; C: x9 ?<th>单元格区域</th>( B+ c0 _; b* D
<th>A (员工ID)</th>! r% C' e: C/ o/ o. s# Z
<th>B (姓名)</th>1 S; v  O: A* H+ H# L" L  H5 z& T
<th>C (部门)</th>
6 P7 {; B# ]) p5 m<th>D (月薪)</th>
" P& S3 L+ Q7 C, ^. h</tr>
' s4 v- K: ~/ p. b. C5 i" i- e  P. O2 Z</thead>1 p( L1 W/ n( m# M8 B; @
<tbody>
( V" f3 G6 R( U- D- L8 I/ B<tr>( m9 d" t, E% K" m
<td>1</td>
( D& u- Q& _( \/ u. s( A" R<td>1001</td>
4 l* m2 D4 j4 w) [<td>张三</td>
: A5 c$ y& x2 ^1 |  g<td>销售部</td>  t: I  h1 c$ A4 s- b, i3 a" O
<td>8000</td>
4 h  c5 q- D7 Y' C</tr>
4 [! c. N* o* b! k' M  U; g<tr>( b1 x! q- w! G4 T
<td>2</td>
3 o* d: a" A0 k  B/ C<td>1002</td>
  \- f: E) w' v0 Q; e" s* M<td>李四</td>- N- h  j3 d1 ^8 e  |
<td>技术部</td>- S8 B  S9 r8 R  C4 o$ C& f
<td>12000</td>
9 y, }2 w/ t; I& Z- D$ c</tr>
+ F! g! ]4 }; @5 X8 s<tr>
+ `7 F- N  N  U/ ~. i<td>3</td>, y- \) l2 |) j  {$ `2 J0 C' }6 Z
<td>1003</td>  G2 y. a, |9 a/ h1 N
<td>王五</td>& u9 R7 V  i4 }) {
<td>销售部</td>
8 a" ?  H- u$ h<td>9000</td>6 x! N' Z& G; ~/ ?
</tr>
5 {; K1 v$ |$ k! S<tr>
; i0 D8 X' X- Z0 o<td>4</td># e0 c: C8 G% O$ o# }9 Z+ p
<td>1004</td>
, U  e3 h( d: m/ m<td>赵六</td>1 _, M( \5 X) I7 U0 D7 `) S2 V
<td>技术部</td>, M7 @. J" Y, ?% F* I
<td>15000</td>
- j. x) \+ b) M3 O, u) n9 `4 _</tr>
6 O+ t! }3 j+ Y( [. P, S8 ^4 X' x<tr>
) v4 ~% O/ }* l  H' f+ k. ?<td>5</td>
' v% B. S! @5 V$ M# ~4 X<td>1005</td>
9 G6 t# j+ [! \" d* `<td>钱七</td>
- F! f6 u- e' r( O<td>市场部</td>4 a$ t9 f! o. |8 Z* i3 X
<td>7500</td>
: `( l! ^* N: e# F5 t5 e4 D, V</tr>
( x, o! V/ l7 b, f  m6 U</tbody>2 a  k2 n9 M% G5 v: x
</table>
4 k3 ]6 E2 }+ w  s<p>后续所有示例均基于此表,数据区域记为 <code>A1:D5</code>。</p>/ R2 U2 A2 L& u/ U6 F, N
<h2>三、初级用法:基础单条件精确查找</h2>5 H* V3 V0 P9 D5 K3 D
<h3>场景1:正向查找(替代 VLOOKUP)</h3>
9 H4 U3 H, z! x% o1 C<p><strong>需求</strong>:根据<strong>员工ID(1003)</strong>,查找对应的<strong>姓名</strong>。</p>$ E) x6 q/ R5 F# @# ?# B
<h4>公式编写</h4>$ s7 B8 U0 I( w
<pre><code class="language-excel">=XLOOKUP(1003, A2:A5, B2:B5)0 \+ ^! [9 A3 y
</code></pre>
3 z6 C8 K) e0 L6 J7 Y- X- \<h4>参数对应说明</h4>) Z5 \% Y) Q" Z) D. W
<table>
6 p" q- o9 i1 O6 b- Y6 }" d  q) K6 u& r<thead>- B7 i9 a# n( a4 x) A! b
<tr>
0 m, D$ O, u& U' x<th>参数</th>
& `* q3 }  h' a7 U' p6 b- n<th>取值</th>
' ?/ a8 z$ T/ a% i- {' |. J<th>作用</th>- ]! H4 c- _4 |1 b; u* ~
</tr>! x- o$ U8 w5 K* M; r, O
</thead>  t" P. u+ V$ Z7 o4 z
<tbody>. W9 v0 L4 X2 {! ~4 Y9 n# R, N
<tr>  V) H2 |1 R* q9 V8 t; t: [
<td><code>lookup_value</code></td>6 |1 N2 J* u0 |$ O7 ?
<td><code>1003</code></td>
0 r. U4 K3 }: [<td>查找目标:要找的员工ID</td>
! {: N# c4 ?! S7 _0 N! K</tr>
- C2 @7 n: K4 |<tr>) F0 ^; ]" N3 m$ y4 |3 o3 d7 m
<td><code>lookup_array</code></td>
; o* K) D, C* J9 `8 D2 y<td><code>A2:A5</code></td>4 ]0 _9 `$ v- P( u
<td>查找区域:存放员工ID的列(A列)</td>
* o5 a. N% x# k/ q6 b! v</tr>7 J) r, ~: y4 H- {" }0 u
<tr>
: j- n! S; x( P6 G<td><code>return_array</code></td>2 r! z, \9 h3 v; |+ [' Y, T0 m
<td><code>B2:B5</code></td>3 A8 ~/ D9 V: D( u
<td>返回区域:存放姓名的列(B列),与A列一一对应</td>5 F4 }# Z0 j2 f
</tr>
- G( v9 [* F& B) ?' |* l# C7 k<tr>. r% L4 z1 C$ b. O9 h7 W6 C  R
<td><code>[if_not_found]</code></td>% o- o7 r1 C3 r+ p0 o$ u# }( V  n
<td>省略</td>2 W5 L+ ^+ T9 X3 A/ y
<td>未找到时返回 <code>#N/A</code></td>
' p4 f' _4 g3 @" o+ y. m+ @</tr>1 d3 Q) u$ Z3 F  g0 a& U& c9 |! X% ~* r
<tr>9 S" V$ r/ l: d. R) G
<td><code>[match_mode]</code></td>
3 ]$ X9 }* T8 i5 j! ?7 N0 t- b<td>省略(默认0)</td>! M  d; K: V8 c& f  B- m5 F
<td>精确匹配,必须找到完全等于1003的值才返回结果</td>, x! {2 y1 s! u7 |* I
</tr>% s7 V3 |9 G8 V7 T: s" b5 V
<tr>
' _  B/ T' p' J  d' x, s& u8 w) a# W<td><code>[search_mode]</code></td>4 {1 k& @# h/ C( Z4 S, ^
<td>省略(默认1)</td>/ g& U" [2 u+ r% m  M- y9 l: ]& M' q
<td>从前往后搜索,找到第一个匹配值即停止</td>
% N/ p  M8 o9 q! s" y' ?# U</tr>- l1 `# D  p8 h; E8 |$ W) [! s
</tbody>& g  m+ _2 H+ u: I. ~8 y4 K3 F, V
</table>
* `+ g3 T! O" H1 q# `, j<h4>结果</h4>/ d6 D: I7 d7 _; |' L
<pre><code>王五
  C1 |/ d7 @% Z7 K- {</code></pre>
" A/ ]+ P2 [; [<h3>场景2:自定义未找到提示</h3>
+ b2 j; p( S- m4 c1 t9 N: u<p><strong>需求</strong>:查找员工ID=1006的姓名,若不存在则返回“无此员工”。</p>
; e8 T( t0 |9 s$ p0 D7 M+ i<h4>公式编写</h4>
/ C/ ^! l, ~4 ?8 g4 h" s<pre><code class="language-excel">=XLOOKUP(1006, A2:A5, B2:B5, &quot;无此员工&quot;)
* @) |7 B9 \; T; y" a- O8 B* U$ q</code></pre>2 U( _% x0 U8 R$ ^: ^/ q/ W
<h4>关键参数:<code>if_not_found=&quot;无此员工&quot;</code></h4>1 N2 V: T$ x% W$ ?5 v7 o0 f
<p>当 <code>lookup_array</code> 中无 1006 时,不再返回 <code>#N/A</code>,而是返回自定义文本。</p>
( V  D6 z7 s3 M$ j6 X  M<h4>结果</h4>
# C7 p" v0 G% m; O: M! r<pre><code>无此员工
2 _  \6 H7 U: I$ |$ N</code></pre>
; m* y1 i# a9 l<h3>场景3:水平查找(替代 HLOOKUP)</h3>
& }( {- p# P: R& _1 d<p><strong>需求</strong>:在水平数据源中,根据<strong>表头(月薪)<strong>查找</strong>张三</strong>的月薪。</p>( ^) \& z' J; j" w$ s! f
<h4>水平数据源(G1:K2)</h4>; i2 f4 r. _0 w0 l8 n' k) Z, F( X
<table>  k/ @3 b: I( @
<thead>4 i5 {+ F$ f0 H5 h
<tr>
2 G* e0 R/ U7 n9 }7 s<th>G1</th>
2 N( ?5 b9 W, h' O: x<th>H1</th>4 p) H( Z' z% j
<th>I1</th>( f/ @2 x8 c* k" e
<th>J1</th>
4 q8 v% v1 n3 R+ d" C# V% L<th>K1</th>
( T$ x, U% g/ v6 p7 n( J1 u</tr>$ l7 v0 A5 t% J0 J1 ~, N  o+ K
</thead>
2 @, z7 l8 ^' i<tbody>) Q1 M8 c5 m& _7 M& p( J
<tr>
$ H& {* D- D) v8 W" U7 |<td>姓名</td>! n5 e( Y9 F' }6 f! P0 N
<td>张三</td>: `) I" w& r0 L' D& Z# ?) C
<td>李四</td>% I  A8 b3 S2 ^  ^* ]2 R# F
<td>王五</td>
" l( O* x' G1 K<td>赵六</td>: i) [( h( w8 q. u& ^/ Z
</tr>/ s0 ]: ~' w" L
<tr>1 H' O6 K" ?- e4 p4 U2 C' f5 U0 r
<td>月薪</td>
; }0 D* j  b) o( S4 i# y<td>8000</td>
; f. F4 f1 M* ^3 G3 T<td>12000</td>- o, J( o1 L, F4 {
<td>9000</td>
/ d% p( y2 @$ T6 m<td>15000</td>
) O6 V9 r. A5 u9 H9 l& U& l</tr>6 I9 Z7 N, l3 B9 m
</tbody>$ `( O5 I8 b- Q" Y1 s" n
</table>9 i' ^/ m# |+ Z4 ~4 y
<h4>公式编写</h4>% I: E+ b. Q  T' P3 k
<pre><code class="language-excel">=XLOOKUP(&quot;张三&quot;, H1:K1, H2:K2)7 E. I: v& D# f6 t; |; Y
</code></pre>
2 P! O" u0 v: i5 P# Y$ g) F. G6 u<h4>参数说明</h4>7 I! m/ Q* g" U5 I
<ul>* m6 j- R5 L/ F8 `; ~
<li><code>lookup_array</code> 和 <code>return_array</code> 为<strong>水平单行区域</strong>,XLOOKUP 自动适配水平查找,无需额外设置。</li>
  q' k2 m0 q1 A: b+ q# Z, ]</ul>
% m5 c7 _$ g3 ^; q<h4>结果</h4>
8 r8 X, Y2 }5 X# _<pre><code>8000
" e" X  A8 P% t0 d+ F% U6 r</code></pre>
8 B( T+ Y3 _; g* u8 A1 L<h2>四、中级用法:反向查找与模糊匹配</h2>7 @$ ^$ e' w8 C! {0 y. }" T
<h3>场景1:反向查找(传统方法需 INDEX+MATCH)</h3>
! G6 {. M) u8 D8 @& D0 i4 O; G<p><strong>需求</strong>:根据<strong>姓名(李四)</strong>,查找对应的<strong>员工ID</strong>(传统 VLOOKUP 无法直接实现,因为姓名不在首列)。</p>
7 v6 s: C5 J% V* Y5 C0 W2 e$ {<h4>公式编写</h4>
, _0 j, P7 N! v+ a4 A0 R<pre><code class="language-excel">=XLOOKUP(&quot;李四&quot;, B2:B5, A2:A5)+ [5 c# T# T6 h0 @
</code></pre>0 Z3 m1 j" R: C, Q6 [, o
<h4>核心优势</h4>
8 p6 W: _. F0 V& D- @7 i" G<p><code>lookup_array</code> 可以是任意列(此处为姓名列 B 列),<code>return_array</code> 可以是左侧的 ID 列 A 列,无需调整数据源顺序,直接实现反向查找。</p>
; s5 n# Q2 v& w( L3 S<h4>结果</h4>! s, U; b6 H0 p7 j
<pre><code>1002; J2 Y+ ~2 l& N3 b+ T
</code></pre>
( w7 \& f7 S. B+ X# {<h3>场景2:通配符模糊匹配(<code>match_mode=2</code>)</h3>
7 W7 q! M7 E' |% i<p><strong>需求</strong>:查找**姓“张”**的员工的月薪(姓名以“张”开头)。</p>
; d& U0 l2 V" U9 B8 Y, S: E<h4>公式编写</h4>  @3 O+ ]( ?) c0 j3 _
<pre><code class="language-excel">=XLOOKUP(&quot;张*&quot;, B2:B5, D2:D5, &quot;无匹配&quot;, 2)
3 d, i: @1 L; X# ?# P$ u. g</code></pre>
. A5 {2 ?. m! S<h4>关键参数解析</h4>
6 K' n/ s# _7 t# Q1 c<table>
8 V: i$ j2 V9 {  S/ L<thead>; m  F; U3 ?8 c* s
<tr>
& x- l5 G8 `+ x7 M( R) Q& q6 O<th>参数</th>  U7 p$ A* Y7 v% n
<th>取值</th>
& u- K0 R  c% b& G8 a<th>作用</th>. t; n& z% \3 r: O7 k0 {" l
</tr>
( _1 F+ D1 c. V) @. I) K</thead>
# _- z( U+ Q8 U! S8 k<tbody>$ A# X" s3 @* Q" g: U- L
<tr>2 b5 O' g9 T/ ~( ]# }
<td><code>lookup_value</code></td>
& U2 n, F9 w$ q! [: v<td><code>&quot;张*&quot;</code></td>
9 ?/ ]; h# k: a4 J; C1 y<td>通配符规则:<code>*</code> 代表任意多个字符,<code>张*</code> 匹配所有以“张”开头的姓名</td>, ~# V8 E7 f( D# o2 m! ~
</tr>! Q/ Y4 P$ _) `" r) B" N9 R2 C
<tr>" Z/ Y" `- v  h# ~
<td><code>[match_mode]</code></td>
  b  w1 ~- Y6 p& y<td><code>2</code></td>; Y, F( {/ m9 p) i, V# L0 }& R
<td>启用通配符匹配模式,支持 <code>*</code>(任意字符)、<code>?</code>(单个字符)、<code>~</code>(转义)</td>
2 M6 E7 [0 c$ w$ \6 e% }</tr>* o' s: f' K7 @
</tbody>5 a1 A% V) Y2 W! w8 G/ X
</table>
6 w+ Q9 R) G3 |+ k9 H* @<h4>结果</h4>; y* K- F$ y  `- J5 T, _
<pre><code>8000/ a$ e/ g- f- D: K+ [, e
</code></pre>2 }. o- z9 \. S! F1 l
<h3>场景3:近似匹配(区间查找)</h3>% S& c6 G; j3 |
<p><strong>需求</strong>:根据<strong>分数(85)</strong>,查找对应的<strong>等级</strong>(等级规则:≥90=优秀,≥80=良好,≥70=中等,&lt;70=及格)。</p>6 c' T; c4 b; D' |5 A6 E
<h4>等级对照表(F1:G5)</h4>
2 p% W: r# Y+ f& r! ^<table>* D* ~( E" W) Q3 p
<thead>
6 a0 R/ _% {" q9 @8 i  T! r; K! A6 @<tr># V2 X) V0 i) q) o5 h
<th>F1 (分数下限)</th>
& ?$ e6 N5 u; [9 Z<th>G1 (等级)</th>
% X$ _: s; H6 T) h2 J</tr>, M+ A5 N7 W. {
</thead>
* X0 b- [4 h( M* a( `2 `5 `) L4 Y<tbody>
/ s4 {  L/ h+ V# g4 \5 {! L<tr>' O- Q2 X5 F2 Y5 |. {# I3 g
<td>90</td>: t! j% L: l1 e1 ]( d
<td>优秀</td>6 p/ g3 O. W6 T# Q. ]4 M
</tr>8 n+ j% Y( x: D! K5 a" |
<tr>
" _9 b# @- P0 z) i& u/ q5 H6 L1 ]/ y<td>80</td>
- Y- z" D( L( Z1 q  }+ Y& `<td>良好</td>; p, C* O+ T1 {& H- O* B
</tr>, [+ m/ y# _1 F# q/ ?3 o) F
<tr>8 ^; Q1 A: l1 [  X0 Z& f" f1 |
<td>70</td>) D& w* L( `" J( A9 ]& u/ o
<td>中等</td>
* k8 L8 w* g" D  k% y8 t</tr>- f3 u! D0 }2 a6 c2 ~3 M5 v
<tr># C# ]# w% N' R5 R, L: F
<td>60</td>
+ ^+ x$ z* f  A<td>及格</td>
9 M0 B1 t% M* i- j+ k</tr>
  \3 ?- R3 j7 D& |! B</tbody>
/ w! a0 N' o$ H3 G: o</table>9 B2 l! m7 l* B: C+ J8 Q; L
<h4>公式编写</h4>
: w  [  Y% a' y2 z" |# {<pre><code class="language-excel">=XLOOKUP(85, F2:F5, G2:G5, &quot;无等级&quot;, 1)8 U( d; ]  X% C: ^0 V
</code></pre>
0 T5 n) y4 K1 ^; g3 b4 b8 _* ]  E<h4>关键参数:<code>match_mode=1</code></h4>
/ l) |  _6 }1 ]  R* u<ul>& |" j% \; ?& C+ m
<li><strong>近似匹配(升序)</strong>:当无精确匹配值时,返回<strong>小于且最接近</strong>查找值的结果。</li>7 m9 [6 N8 r* c: l; y
<li>要求 <code>lookup_array</code> 必须按<strong>升序排列</strong>。</li>- ~8 B! N' e2 U- a5 X
<li>85 无精确匹配,小于85且最接近的是80,对应等级“良好”。</li>8 P+ x+ }" Q4 U, E7 y
</ul>
, b4 s" a/ q9 M+ {<h4>结果</h4>6 `8 ~8 S9 P$ B) i
<pre><code>良好
9 W: d; s% s7 R6 i$ u' a( e( L</code></pre>3 w9 \0 R0 x9 D! @0 e/ l4 K9 N
<h3>场景4:从后往前搜索(<code>search_mode=-1</code>)</h3>( ^  q% i% w7 a/ S
<p><strong>需求</strong>:查找<strong>销售部</strong>最后一位员工的姓名(数据源中有2个销售部员工:张三、王五)。</p>. }2 }8 F  a8 D; T2 F
<h4>公式编写</h4>1 H# r! |6 ^, g& V; ~. d) A2 ]
<pre><code class="language-excel">=XLOOKUP(&quot;销售部&quot;, C2:C5, B2:B5, &quot;无&quot;, 0, -1)
' p" x) o! Q" e4 Q: O</code></pre>) C2 a. e0 @- U: V5 o" F5 U
<h4>关键参数:<code>search_mode=-1</code></h4>
" s: `- A/ g+ X<ul>
) n: F0 F0 Q6 m1 \<li>从后往前搜索,找到<strong>最后一个匹配值</strong>即停止,而非第一个。</li>
9 l% l. Z" b9 H* f0 i; {<li>销售部对应的姓名是张三(第1个)、王五(第2个),从后往前搜会返回王五。</li>
' h! K/ `) [7 i</ul>
% z9 v' f2 B  a# \  \; J- x6 u<h4>结果</h4>7 `, i6 j' W: ~6 K
<pre><code>王五
) M0 [) e5 D$ \* {1 c2 U</code></pre>
6 V# k- P' H( [9 s/ S<h2>五、高级用法:多条件查找与函数嵌套</h2>
3 Z: n$ z5 X5 ?6 s7 E+ [5 j<h3>场景1:多条件查找(用 <code>&amp;</code> 连接条件)</h3>' b9 z6 a0 x$ Y! |) T5 s
<p><strong>需求</strong>:查找**部门=技术部 且 月薪=15000**的员工姓名。</p>: O5 m# }1 K* ~, Q8 j1 _! R
<h4>公式编写</h4>2 H" Z! Y) \$ G5 D" z! ]; Z
<pre><code class="language-excel">=XLOOKUP(1, (C2:C5=&quot;技术部&quot;)*(D2:D5=15000), B2:B5, &quot;无匹配&quot;)+ |4 E9 Y. B9 W1 H! v  r" a9 N
</code></pre>5 z4 [2 Z: V, k6 L  K
<h4>核心逻辑解析</h4>8 q$ S5 B) d8 L7 a( E
<ol>% ]$ n- P7 w. F* E" ?# p; x5 _
<li><strong>构造条件数组</strong>:4 g. R5 D, M! X( i7 V: X
<ul>
) R) F  ^+ V8 _6 N<li><code>(C2:C5=&quot;技术部&quot;)</code> 生成布尔数组 <code>{FALSE, TRUE, FALSE, TRUE, FALSE}</code></li>
  R. B) u5 S7 x  x/ d<li><code>(D2:D5=15000)</code> 生成布尔数组 <code>{FALSE, FALSE, FALSE, TRUE, FALSE}</code></li>' n- ^% Z# b$ a
<li>两个数组相乘 <code>*</code>,布尔值自动转为 0/1,结果为 <code>{0, 0, 0, 1, 0}</code></li>% {; v% M3 d& u- r! J1 \
</ul>1 N; ^4 k( R0 h0 |$ x9 Q
</li>
6 H% z4 R6 U, e6 z8 Q6 B<li><strong>查找目标设为1</strong>:<code>lookup_value=1</code>,即找到条件同时满足的位置(值为1的元素)。</li>
/ F+ ]5 W" A- G9 a7 ~<li><strong>返回对应姓名</strong>:值为1的位置对应姓名“赵六”。</li>7 t: k$ W) V2 @) K
</ol>
# t8 C. H8 x  X1 n: |# P; O* I- o<h4>结果</h4>4 V. c5 ?8 ^& D. z: ~
<pre><code>赵六3 T. v  `+ `; s$ |4 d
</code></pre>
2 t0 H! n1 a: g# K0 ?! D<h3>场景2:动态数组溢出(返回多个结果)</h3>
' T3 U" @" D7 w4 a<p><strong>需求</strong>:查找<strong>所有销售部员工</strong>的姓名(返回多个结果,自动溢出到单元格)。</p>
& H. W' V9 q: ~  c' |1 y5 [+ J/ J<h4>公式编写</h4>
8 e& q% M% H( B  q1 B<pre><code class="language-excel">=XLOOKUP(&quot;销售部&quot;, C2:C5, B2:B5, &quot;&quot;, 2, 1)4 `7 b8 a+ J+ d, ~9 s, n( X
</code></pre>6 O; l* |: \8 m7 q+ w
<h4>关键特性:动态溢出</h4>
. w+ d7 X' a% }  }) t, W<p>当 <code>lookup_array</code> 中有多个匹配值时,XLOOKUP 会返回<strong>所有匹配结果</strong>,自动向下溢出到相邻单元格(需 Excel 365 动态数组支持)。</p>
! ], u4 J: K/ M<h4>溢出结果</h4>+ E' c5 s# e3 Y; }4 z' e
<table>, a  A! Q; p# \
<thead>
  ?4 A, ]* Y2 l0 k: S' W0 ?<tr>
7 H# e5 d& s: |: K2 W5 ~<th>单元格</th>$ K# T5 T& U- b' m. F4 C% K$ G
<th>内容</th>5 \4 J) I% C8 L) c
</tr>- V" P& R5 e$ u
</thead>4 y! b0 k, v* L7 B  q$ L
<tbody>
! y) L' g. C) x% ?<tr>8 J' t# u# m  T! C7 t! R/ [% d
<td>E2</td>( x$ c. H% \2 K( l9 b( o
<td>张三</td>3 I; c( F' B) ^' W0 i  e& P
</tr>) A5 I* V. A& x* \( {5 h$ J
<tr>4 E* h3 @8 V  r
<td>E3</td>' g8 r- k' w9 I5 ]) F2 D
<td>王五</td>
, `  p  A4 L4 }1 o& S; E</tr>  d5 x6 k- N& |8 e! j
</tbody>6 d- Z' p) {8 O0 W; B4 {
</table>
7 p, e! E- l- Z0 W<h3>场景3:嵌套 SORT 排序查找结果</h3>0 f* Y- z/ f" X, P
<p><strong>需求</strong>:查找所有技术部员工的月薪,并按<strong>降序排序</strong>。</p>
' n7 N% t5 [0 s3 v1 R<h4>公式编写</h4>
- X! R- s! H2 R- e. u8 c: v" {<pre><code class="language-excel">=SORT(XLOOKUP(&quot;技术部&quot;, C2:C5, D2:D5, &quot;&quot;, 2, 1), 1, -1)
" U5 E) T; B  g- R- n: R% T/ g9 M  a</code></pre>, N" k2 a$ l; L$ v4 e( ^
<h4>嵌套逻辑</h4>" l: u$ E  T% p- n  M  s  m" U7 J
<ol>2 ?- a" _/ f! }: e% q0 l, N
<li>先用 <code>XLOOKUP</code> 提取技术部所有月薪,返回数组 <code>{12000, 15000}</code>;</li>  I* M! ]( }. Q' j& ^# \. Q
<li>再用 <code>SORT</code> 函数对数组按第1列(唯一列)降序(<code>-1</code>)排序;</li>. @9 h! }$ I5 K7 _7 H3 k- z4 S
<li>最终结果自动溢出。</li>; B) `# j/ o5 S7 x$ Y$ N1 c4 V
</ol>+ s' U* ^9 M5 l% ?) s
<h4>溢出结果</h4>
' E* J7 m: Z9 e% g! \<table>" K# {) v* D2 }( D5 w. e0 D' x; g
<thead>
9 h5 Y/ w% ^" |<tr>9 Q% [# s# h: o+ K4 a( ^
<th>单元格</th>& B2 M; x8 ^9 a/ @' W' s
<th>内容</th>
- S$ [5 G* f9 h1 N4 y</tr>
9 _; s1 R2 I5 C. g' I</thead>
. D8 j) d8 Q( M6 X<tbody>
/ b* i. m; b* f4 E5 V<tr>" B- d/ J; f$ d  z' `# F1 @, g
<td>E2</td>% s& _% ?' B" X. X$ p+ d) v  a% g1 f
<td>15000</td>
- Q8 y. ]( @9 a</tr>
4 s$ v8 g7 {7 O  `8 f9 H<tr>5 Z7 _6 p- Y" D: y" C& F9 L# {. t
<td>E3</td>: W; ?$ w" _0 d
<td>12000</td>
' t% B9 s! v& Z/ {* \</tr>
2 Y! x6 X$ s4 \# s! d</tbody>/ s' @( Z, W: i. B2 \
</table>, k! [+ U$ m! k5 T* q5 w9 \$ ^
<h3>场景4:与 FILTER 嵌套实现更灵活筛选</h3>/ Y) O2 O# p( @
<p><strong>需求</strong>:查找<strong>月薪>8000</strong>的员工姓名和部门,返回两列结果。</p>7 ^  H0 ]0 X6 R9 z4 Y
<h4>公式编写</h4>' k4 C- T0 m  ]( |- q! i
<pre><code class="language-excel">=FILTER(HSTACK(B2:B5, C2:C5), D2:D5&gt;8000)9 x0 e) y' `+ C8 {1 Z6 ?
</code></pre>
1 H4 ]) i) O* \- b' U<blockquote>
2 {  K6 ]8 O( ]5 ], k2 [/ i8 W' F<p>补充:XLOOKUP 单条件返回单列,多列结果建议用 <code>FILTER</code>+<code>HSTACK</code> 嵌套,更高效。</p>+ n/ H4 _( t2 N4 d8 S2 V) @8 g
</blockquote>
  g& z. ^# w) c. o$ K9 ?7 i1 I' V6 }<h4>结果(溢出两列)</h4>" X1 f0 X' D! S! y* L; k$ L2 {7 x  C
<table>
  u5 Q+ d7 O* c: o& y<thead>3 u5 a4 z5 B! D- e; y' ^2 X1 ?) G# ]
<tr>. [/ M/ q+ [% j2 G7 g
<th>姓名</th>. n1 A+ }9 @9 q" Z9 M: i, {1 B7 B& Z* D
<th>部门</th>" s8 O8 ?) r: L# V3 j
</tr>
2 s! d2 {7 x2 [! a& m; ?0 t</thead>2 i$ v& e; B  i4 r% Y' j
<tbody>; s9 Z9 p2 V' d$ V
<tr>
0 n0 P5 R/ u. M/ g2 i9 F/ }  ^; \4 i<td>李四</td>7 m1 x  h  }! o
<td>技术部</td>% ]$ k  ]2 _9 k/ |, _
</tr>/ v- x6 a" X4 c, H
<tr>$ Z& m. K% p6 U/ V1 Y" I) ?
<td>王五</td>$ W0 f" C' K/ L/ Z
<td>销售部</td>
: m' x; u- L* d9 j9 @: U</tr>$ @1 y- P3 G) N1 t' q
<tr>0 j# p$ i& e* {3 h! |
<td>赵六</td>6 p  u8 Q( ?3 S" ^( k0 W
<td>技术部</td>
- O  x$ m- b8 Z$ l: h* w</tr>
- R+ _8 @" ?; @9 u</tbody>
1 u  w2 d0 v$ I+ ^# I</table>/ \% T8 Q  i  X+ @& j/ k7 [
<h2>六、常见问题与注意事项</h2>+ P; m. c, F. @
<ol>. _! C2 M$ h0 g! s. ]7 P
<li>
5 Z( x$ B& T, K" B- d<p><strong><code>#N/A</code> 错误的解决</strong></p>  ^2 D6 k1 o+ @2 d- t2 |- u
<ul>
3 k1 n4 L. U% ^<li>原因:<code>lookup_array</code> 中无匹配值且未设置 <code>if_not_found</code>;</li>, }. f& V4 {8 |0 ?4 G6 z7 }
<li>解决:添加 <code>if_not_found</code> 参数(如 <code>if_not_found=&quot;无数据&quot;</code>)。</li>9 C/ q& A# a$ z2 t/ y3 _
</ul>' J' j1 S: r; R. b' k5 ?
</li>. M+ E; u0 X) R: f3 S
<li>
* X- U) W5 N" P, h! y1 q4 `<p><strong><code>#SPILL!</code> 错误的解决</strong></p>
  m9 y+ A( |# O<ul>
+ Z! r% Z. v9 B<li>原因:溢出结果区域被其他单元格内容阻挡;</li>  c% C) X3 C  l+ h3 ?0 N/ \- u& T
<li>解决:清空目标区域下方/右侧的空白单元格,确保溢出空间充足。</li>8 Q7 O7 Q! X, G- e9 J& f
</ul>
8 s; c7 B, q2 w. F6 F* O. a</li>
4 N1 L' h* \( u1 B  d9 X. L8 b<li>8 ]0 v  V4 Z4 d$ B! P
<p><strong><code>lookup_array</code> 与 <code>return_array</code> 长度不一致</strong></p>  f) `, r; U8 {9 [
<ul>
9 ~: t' \4 P5 U<li>报错:<code>#VALUE!</code>;</li>& L1 K: f2 g( ^) R. s
<li>解决:确保两个区域的<strong>行数/列数完全相同</strong>(如均为 4 行 1 列)。</li>- D! J& }0 ]5 N- m1 ~- ]
</ul>
' P# ?" ?6 g# ~+ x</li>
; w- W$ F" \- W+ Z<li>! n3 h: d/ Q8 d" ?+ i7 H
<p><strong>近似匹配的排序要求</strong></p>
$ ?1 F/ u3 j6 H9 J$ s/ k" k- P5 N<ul>1 a, c3 f% B/ c5 t8 x( ]3 l
<li><code>match_mode=1</code>(升序近似):<code>lookup_array</code> 必须升序排列;</li>
# R* [/ t2 w- o2 f" ^5 P9 Q, A1 F<li><code>match_mode=-1</code>(降序近似):<code>lookup_array</code> 必须降序排列;</li>, E7 R  A4 P0 y: i. S* k8 {5 |
<li>否则会返回错误结果。</li>
2 H2 }2 H/ c0 U) o8 l! I</ul>
- Y* O% V' G( G5 Q3 x</li>
9 T. m. d* t2 H5 ~/ ^<li>( b4 Q! r4 z# R; d7 D
<p><strong>通配符的转义使用</strong></p>3 }" B& V5 A3 Q
<ul>
9 |1 C6 m! m: ?$ X<li>若需查找实际的 <code>*</code>/<code>?</code>,需在前面加转义符 <code>~</code>,例如查找 <code>A*</code> 需写 <code>A~*</code>。</li>
4 v) f3 o, R# L</ul>* H/ Y# I& \& R
</li>, Z7 |4 F; M% N# m
</ol>( s" o8 e0 R  Z
<h2>七、XLOOKUP 对比传统查找函数的优势</h2>+ b" }+ q7 a7 j6 }8 Q2 V7 i
<table>
7 {" P% U6 U8 ^<thead># M5 ^2 P* i+ [- E  d' g: e  z
<tr>
9 ~2 h7 I* ?5 v( J<th>功能特性</th>/ [; F0 h9 |8 N; R& z
<th>XLOOKUP</th>/ G6 ^3 S0 l/ O9 N$ P
<th>VLOOKUP</th>0 V8 M) Q; N) i1 g  y% G: Q+ C
<th>HLOOKUP</th>$ G# U8 @& {  _" Y6 [& z( H
<th>INDEX+MATCH</th>
9 ^6 f8 h! _' h: U  x( `</tr>! F, |5 ?% V% n( y: m; [
</thead>
7 R2 Y0 H+ w7 ^9 m3 }  S+ h<tbody>
* C9 e7 \4 V) y/ D' x<tr>
& J& s) o) b& y$ |) h3 a$ Y<td>查找方向</td>3 N1 J" ]3 g* b: Y4 N! _7 P7 ^9 ?  ]
<td>任意方向(行/列)</td>! O; Q1 A) n7 V" c9 w+ r( t; m
<td>仅垂直(列)</td>
* V& Q' p8 {, E9 t* c% i) y<td>仅水平(行)</td>
  T- U4 @% B0 f& X<td>任意方向</td>  c$ u8 P: h  w6 h& ^- H
</tr>
  @! K2 R# W; O. h% E: }# @<tr>3 M) O5 _2 |* d7 M  u9 E) ^/ a7 e
<td>反向查找</td>) N' F1 b0 b' x+ A, S, ^" s8 H+ P
<td>直接支持</td>
2 R; O, H* l4 I4 O, ?4 p5 n2 Y/ P<td>不支持(需调整数据源)</td>
1 \- W+ b7 E! B" _<td>不支持</td>" }" u  O, Y) U7 v9 G, c3 ^
<td>支持(公式复杂)</td>
( [0 ^$ q6 w& ~8 W* N</tr>; S( Q, ~: N% ~1 ?. K' t( `7 b
<tr>! E& m* Z: x  Y" ]! F9 O7 {" E! s
<td>多条件查找</td>
" k& X6 `. \$ `- G<td>支持(数组相乘)</td>
5 \- x6 U% f. \: C2 C<td>不支持</td>
* t% K, b# d" \: C' p% i  B<td>不支持</td>! ?; x4 U" v& U" `
<td>支持(公式复杂)</td>" i" b. b7 x' Z. D& G
</tr>5 R/ R# _. z) G6 e. R* b8 t7 ]
<tr>7 V1 j# ]3 q* Z2 b$ j# @$ B% p
<td>未找到默认值</td>: y, ^  ^1 r+ [  H4 x
<td>内置参数</td>
! p7 q2 P8 e; Q: X: g: U. b# c<td>需嵌套 IFERROR</td>
+ G' t5 z  u4 E% {<td>需嵌套 IFERROR</td>
- a9 u! H, B) [<td>需嵌套 IFERROR</td>
/ H! z4 x$ Z5 l! g</tr>
. h! f, }; h6 O+ X<tr>  y7 Y/ Q8 }$ p- _8 w0 `+ ^" e8 Q
<td>搜索方向</td>* J5 R% t1 D; k
<td>支持从后往前</td>- s* O$ W- @6 {9 H# Q0 s4 @8 H
<td>仅从前往后</td>4 u$ S' \: m3 x
<td>仅从前往后</td>
  ^* p6 j$ W9 a$ i<td>支持(需复杂设置)</td>" [) f, ?! i2 H' l8 P0 ]( c' E# S
</tr>
' ~" ]( E2 ~$ R  T' p<tr>
( c! A3 [. A2 r: L<td>通配符匹配</td>
: [( |4 v2 r0 u+ j  e" d, q<td>内置参数</td>
" w8 U( |# P7 k! T1 @( j% H+ y<td>支持(需手动设置)</td>
/ `" L0 q( U" E: p<td>支持(需手动设置)</td>8 H( h  T% A, i' u8 Z3 @8 }
<td>支持(需手动设置)</td>
# Q  A. o  \* X/ J  h4 G' b# ^</tr>
3 t0 t; T" A1 H0 y</tbody>
- D' S( O1 U2 s2 y& }</table>
' d1 X2 z- F6 z: e- E
d94295e4de394fb78c498cc0286bf45e.webp
匠心独运,千锤百炼,品质非凡。
回复 转播

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

您需要 登录 后才可以回复,轻松玩转社区,没有帐号?立即注册
快速回复
关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表