Excel:如果一行中的任何字段不为空,请将第一列中的单元格设置为递增行号?
我正在尝试创建一个公式,当在行的任何列中输入任何数据时,该公式将自动将增量行号添加到电子表格的第一列。
例如,如果我的表如下所示:
a b c d e f
1 # x x x x x
2 # x x x x x
3 # x x
4 # x
5 # x
我希望将“a”列读取为:
0
1
2
3
4
如果我在任何列中添加更多数据,例如:
a b c d e f
1 # x x x x x
2 # x x x x x
3 # x x x
4 # x x
5 # x x
6 # x
7 # x
然后它会自动将索引行“a”读取为:
0
1
2
3
4
5
6
I希望这是有道理的!任何帮助,甚至只是一个指导我正确方向的教程,将不胜感激!
答案是:
=if(counta(B2:F2)>0,A1+1,"")
以上有效!感谢 Alan Whitelaw 的回答,仅将其发布给其他人,因为它具有固定的语法。
I'm trying to create a formula that will have the effect of automatically adding an incremental row number to the first column of my spreadsheet when any data is entered in any column of the row.
So for example, if my table looks like this:
a b c d e f
1 # x x x x x
2 # x x x x x
3 # x x
4 # x
5 # x
I would like the 'a' column to read:
0
1
2
3
4
And if I added more data in any column, e.g.:
a b c d e f
1 # x x x x x
2 # x x x x x
3 # x x x
4 # x x
5 # x x
6 # x
7 # x
It would then automatically up the index row 'a' to read as:
0
1
2
3
4
5
6
I hope this makes sense! Any help, or even just a tutorial to point me in the right direction would be so appreciated!
Here is the answer:
=if(counta(B2:F2)>0,A1+1,"")
The above works! Thanks to Alan Whitelaw for the answer, only posting this for others as it has the fixed syntax.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,并且工作表将始终按行“按顺序”填充,这应该可以将
其弹出到
A2
中,其中B2:D2
是其余的要测试的行。Excel 的 counta() 对非空白单元格进行计数。
If I undersand corectly, and the sheet will always be filled in "in order" down the rows this should work
Pop this in
A2
, and whereB2:D2
is the rest of the row to test.Excel's counta() counts non-blank cells.