Excel:有一个函数可以返回满足匹配条件的范围吗? [英] Excel: is there a function that returns a range for satisfying the matching condition?

查看:68
本文介绍了Excel:有一个函数可以返回满足匹配条件的范围吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个与后续行(在同一列上)进行比较的值,并将范围返回到该值首次更改的行.

Given a value compare with the subsequent rows (on the same column) and return the range upto the row where the value changes for the first time.

Example:
   A
1  cat
2  cat
3  cat
4  dog
5  cat

要返回的范围是A1:A3.

The range to be returned is A1:A3.

推荐答案

假定单元格 c1 中有cat,下面的公式将返回第一个连续匹配范围.输入 ctrl + shift + enter

Assuming you have cat in cell c1, the following formula will return the first continuous matching range. Enter with ctrl+shift+enter

= COUNTIF(OFFSET(A1:A5,MATCH(C1,A1:A5,0)-1,0,MATCH(TRUE,OFFSET(A1:A5,MATCH(C1,A1:A5,0),0)<> C1,0)),"cat")

如果您的数据始终以A1开头,并且您希望整个范围都与第一个值匹配,一直到下一个值,请使用以下数组公式(在 ctrl + shift中输入 + 输入):

If your data always start in A1 and you want the whole range matching the first value, all the way until the next value, use the following array formula (entered with ctrl+shift+enter):

=OFFSET($A$1,0,0,MATCH(TRUE,A:A<>A1,0)-1)

这篇关于Excel:有一个函数可以返回满足匹配条件的范围吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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