Try this array formula** entered in N4 and copied down:
=COUNT(M4:INDEX(A4:M4,MATCH(TRUE,A4:M4<>0,0)))
** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
Note that your sample file is set to manual calculation.
Bookmarks