View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Count within a Range Q

Try this function. Put it in a module. Alt +F11 to open VB editor, rght click
'this workbook' insert module and paste it in

Function countblanks(range As range)
rangesize = range.Cells.Count
For Each c In range
If IsEmpty(c) Then
Count = Count + 1
x = x + 1
Else
x = x + 1
If x < rangesize Then
Count = 0
End If
End If
Next
countblanks = Count
End Function

Call with
=countblanks(a5:a20)
Change the range to suit

Mike

"Sean" wrote:

Thanks Bob, I'm getting a value 2 returned, the answer I am expecting
is 3

I have A15 populated and A19, thus A16:A18 are <blank, so answer
should be 3 (everything else is blank also in A)