Excel - 用于跳过公式中的行的逻辑 [英] Excel - logic for skipping rows in a formula

查看:313
本文介绍了Excel - 用于跳过公式中的行的逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过公式而不是VBA /宏执行以下操作(我不想要一个复制/粘贴特殊解决方案,因为我需要更多的控制)。有可能:



我有一列,其中有一些空白行和一些带有值的行。我们来调用该列A.在列b中,如果列A有一个值,我只想复制单元格。如果没有,我希望它跳到列A中的下一个单元格,但是保持在同一个单元格的列b。



列A

1

2

[空白]

4

[空白]

6



我希望列b输出为(但没有空行)。这将意味着公式将需要循环并且有一些循环跳过逻辑:

1

2

4

6



通常我只是设置单元格B1 = A1来复制,但是由于我想跳过列A中空白的行,我不知道该怎么做除了一个宏之外。我可以使用阵列还是任何其他创意解决方案?最终,我也会使用这个具有特定值(不只是空格)的项目。



谢谢!



= IFERROR(INDEX(Range,SMALL( IF(Range = criteria,ROW(Range)-MIN(ROW(Range))+ 1),ROWS(C $ 2:C2))),)



确认使用 CTRL + SHIFT + ENTER



所以在这里,如果你的数据在A1:A10,你想要从B1结果



= IFERROR(INDEX(A $ 1:A $ 10,SMALL (IF(A $ 1:A $ 10<> 中,ROW(A $ 1:A $ 10)-ROW(A $ 1)+1),行(B $ 1:B1))), )



确认使用 CTRL + SHIFT + ENTER / p>

当您的资料用尽时,您将获得空白


I am trying to do the following via a formula rather than VBA/macro (i do not want a copy/paste special solution as i need more control). is it possible to:

I have a column in which there are some blank rows and some rows with values. let's call that column A. In column b, i only want to copy the cells if the column A has a value. if it doesn't, i want it to skip to the next cell in column A, but stay on on the same cell for column b.

Column A
1
2
[blank]
4
[blank]
6

i want column b output to be (but with no blank rows). this would imply that somehow the formula would need to loop and have some loop skipping logic:
1
2
4
6

Normally i would just set cell B1 = A1 to copy it over, but since i want to skip rows that are blank in column A, i'm not sure what to do besides right a macro. Can i use an array or any other creative solution? Eventually, i would also use this for items with specific values (not just blanks).

thanks!

解决方案

Generically in cell C2 copied down....

=IFERROR(INDEX(Range,SMALL(IF(Range=criteria,ROW(Range)-MIN(ROW(Range))+1),ROWS(C$2:C2))),"")

confirmed with CTRL+SHIFT+ENTER

so here if your data is in A1:A10 and you want results from B1 down

=IFERROR(INDEX(A$1:A$10,SMALL(IF(A$1:A$10<>"",ROW(A$1:A$10)-ROW(A$1)+1),ROWS(B$1:B1))),"")

confirmed with CTRL+SHIFT+ENTER and copied down

when you run out of data you get blanks

这篇关于Excel - 用于跳过公式中的行的逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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