• If you would like to post, please check out the MrExcel Message Board FAQ and register here. If you forgot your password, you can reset your password.
  • Excel articles and downloadable files provided in the articles have not been reviewed by MrExcel Publishing. Please apply the provided methods / codes and open the files at your own risk. If you have any questions regarding an article, please use the Article Discussion section.
Jeffrey Mahoney

Visible Rows, Dynamic Row Numbering, Conditional Formatting, and Formulas

Excel Version
  1. 365
Using Subtotal on every row of your range table, you can display sequential row numbers for visible rows only. With that you can also fill every other row with a cell color just like a defined Excel Table even when rows are filtered. You can also use ****IFS functions to get results for visible rows only.

Dynamic Row Numbering
The Key to the whole thing is the formula in cell A3. It shows a row number only if the row is visible (not filtered out).
=LET(VIS,SUBTOTAL(103,B3),IF(VIS=1,VIS+MAX(A$2:A2),0))

Dynamic CF
To get Conditional Formatting to fill cell color for alternating rows, use this formula. Even if you filter out rows, the CF will show correctly
=MOD($A3,2)=0
If you want to color every third row use
=MOD($A3,3)=0

Dynamic Functions
And then finally to get the Sum, count, max, min, or average value of just the visible cells, use a formula like this. The bold part specifies to use only cells in column A that are not zero. You can also use FILTER with other functions for a wider variety of results
=COUNTIFS(C3:C162,"Active",A3:A162,"<>"&0)


Book2
ABCD
1Active Count:95
2VIS ROWIDStatusName
31840.02ActiveJackie
421263.13ActiveBen
531517.7ActiveJohn
641571.02ActiveBen
751641.1ActiveBill
861418.23ActiveJeff
971571.02ActiveBen
1081392.35ActiveAlfie
1191392.41ActiveAlfie
12101526.2ActiveJenn
Sheet3
Cell Formulas
RangeFormula
C1C1=COUNTIFS(C3:C162,"Active",A3:A162,"<>"&0)
A3:A12A3=LET(VIS,SUBTOTAL(103,B3),IF(VIS=1,VIS+MAX(A$2:A2),0))
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet3!$A$2:$D$162A3:A12
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A3:D162Expression=MOD($A3,2)=0textNO
B3:B162Expression=AND(B3<1000,MOD(B3,1)=0)textNO
  • Like
Reactions: Sufiyan97
Author
Jeffrey Mahoney
Views
1,213
First release
Last update

Ratings

5.00 star(s) 1 ratings

More Excel articles from Jeffrey Mahoney

Latest reviews

Useful tips provided in a concise manner.

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top