使用excel vba中的内置函数在列中找到最后一个匹配项 [英] find last match in column using built in functions in excel vba

查看:888
本文介绍了使用excel vba中的内置函数在列中找到最后一个匹配项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有相同客户端ID的多个实例的excel工作簿。所以客户端可以在列表中多出现一次。我想找到客户端ID的最后(最接近底部)实例,所以我可以查看同一行的其他信息。 VLOOKUP显示第一个实例,我需要最后一个。



那么,如何使用内置函数找到给定客户端ID的最后一个实例?我不想写一个宏来做这个。

解决方案

假设你想找到id id_1范围 A2:A8 并从范围返回相应的值B2:B8 ,然后使用:

  = LOOKUP(2,1 /(A2:A8 =id_1),B2:B8 )






如果要返回索引 ID id_1的范围 A2:A8 中使用:

  = MATCH(2,1 /(A2:A8 =id_1))

与数组条目( CTRL + SHIFT + ENTER



如果您要返回id id_1的最后意义行号,请使用:

  = LOOKUP(2,1 /(A2:A8 =id_1),ROW(A2:A8))


I have an excel workbook with multiple instances of the same client ID. So, a client can appear more than once in the list. I would like to find the last (closest to the bottom) instance of the client ID so i can then look along that same row for additional information. VLOOKUP shows the fist instance, I need the last.

So, how do I find the last instance of a given client ID using built in functions? I'd rather not write a macro to do this.

解决方案

Suppose you want to find last instance of id "id_1" in range A2:A8 and return corresponding value from range B2:B8, then use:

=LOOKUP(2,1/(A2:A8="id_1"),B2:B8)


If you want to return index of last intance of id "id_1" in range A2:A8, use:

=MATCH(2,1/(A2:A8="id_1"))

with array entry (CTRL+SHIFT+ENTER).

If you want to return row number of last intance of id "id_1", use:

=LOOKUP(2,1/(A2:A8="id_1"),ROW(A2:A8))

这篇关于使用excel vba中的内置函数在列中找到最后一个匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆