Excel2016无UNIQUE/FILTER函数时同地址住户姓氏匹配方案问询
解决方案
你无需编写VBA代码,使用Excel 2016原生支持的普通函数即可实现需求,操作方法如下:
实现公式
你已经提前完成了姓氏提取、街道出现次数统计的辅助列,直接在Result列输入以下公式即可:
=IF(SUMPRODUCT(--(COUNTIFS([Street],[@Street],[Last Name],"<>"&[@[Last Name]])>0))=0,"Match","Alert")
公式逻辑说明:
- 内层
COUNTIFS会统计当前行对应街道下,姓氏和当前行姓氏不一致的条目数量 - 外层
SUMPRODUCT做聚合判断,若返回值为0,说明当前街道下所有住户姓氏完全一致,返回Match;只要存在不一致的姓氏就返回Alert
额外可选优化
如果你只需要对出现次数≥2的街道做比对,可以在公式外层新增判断逻辑,减少不必要的计算:
=IF([@[Street Count]]<2,"无需比对",IF(SUMPRODUCT(--(COUNTIFS([Street],[@Street],[Last Name],"<>"&[@[Last Name]])>0))=0,"Match","Alert"))
样表验证结果
对应你提供的样表,公式返回结果如下:
| ID#s | Name | Last Name | Result | Street | Street Count |
|---|---|---|---|---|---|
| 1 | Brown Bob | Brown | Match | Address 1 | 2 |
| 2 | Brown Sue | Brown | Match | Address 1 | 2 |
| 3 | Green Adam | Green | Alert | Address 2 | 2 |
| 4 | Chruchill John | Chruchill | Alert | Address 2 | 2 |
| 5 | Smith Gary | Smith | Match | Address 3 | 3 |
| 6 | Smith Lisa | Smith | Match | Address 3 | 3 |
| 7 | Parker Peter | Parker | Match | Address 4 | 1 |
| 8 | Parker Lewis | Parker | Match | Address 4 | 1 |
| 9 | Smith Evan | Smith | Match | Address 3 | 3 |
内容的提问来源于stack exchange,提问作者Zachary Blankenship
相关产品推荐
相关产品推荐

