View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Counting specific number following decimal point in a row

Hi,

Am Mon, 23 Mar 2015 13:11:21 -0700 (PDT) schrieb :

150.1 153.2 154.3 155.1 155.1 157.1 157.4

I would like to count how many cells have 0.1 given the condition that they are between those cells that start with 0.3 and end with 0.4


try it with an UDF:

Function myCount(myRng As Range) As Long
Dim i As Long

With myRng
For i = 1 To .Cells.Count
If Round(.Cells(i) - Int(.Cells(i)), 1) = 0.3 Then
Do
i = i + 1
If Round(.Cells(i) - Int(.Cells(i)), 1) = 0.1 Then
myCount = myCount + 1
End If
Loop Until Round(.Cells(i) - Int(.Cells(i)), 1) = 0.4
Exit For
End If
Next
End With
End Function

And call the function into the sheet with
=myCount(A1:G1)


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional