View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default count cells since last non-zero value

Hi Bruce,

Enter into A11:
=ending_zero_cells(A1:A10)

and define the UDF
Option Explicit

Function ending_zero_cells(r As Range) As Long
Dim rcell As Range
Dim i As Long
i = 0
For Each rcell In r
If rcell.Value = 0 Then
i = i + 1
Else
i = 0
End If
Next rcell
ending_zero_cells = i
End Function

HTH,
Bernd