开发者

Excel: if any field in a row is not null, set the cell in the first column to an incrementing row number?

开发者 https://www.devze.com 2023-03-05 01:49 出处:网络
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.

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' 开发者_C百科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.


If I undersand corectly, and the sheet will always be filled in "in order" down the rows this should work

=if(counta(B2:D2)>0,A1+1,"")

Pop this in A2, and where B2:D2 is the rest of the row to test.

Excel's counta() counts non-blank cells.

0

精彩评论

暂无评论...
验证码 换一张
取 消