In a range with filter, I want to have a column of row numbers which will change according to the filter, so that rows always count consecutively from 1. For example, the following is a range with filter:
Number Name Gender
1 Alice F
2 Jason M
3 Ka F
4 Fiona F
5 Albert M
Now suppose we apply a filter to show rows where Gender is M:
Number Name Gender
2 Jason M
5 Albert M
The above is what Excel normally shows, but I want the Number to count from 1 consecutively like this:
Number Name Gender
1 Jason M
2 Albert M
So, the rows should be renumbered according to the filter. I have tried something like =MAX(...)+1
or using the SUBTOTAL()
function, but I haven't succeeded yet. Is it possible to write a formula for the Number column to do this task? How?