Hi I want to create a function to count the number of values in an array which have specific characteristic and need your help here:
Basically the list of array is like below (cut short a bit alr):
1111111 1111110 1111101 1101001 1011111 1011110 1011101 1011100 1011001
and I have a value in a cell A1 (let's say 1101001)
I want to count the number of values in the array which are larger than the value in cell A1 and the difference between a specific value and cell A1 has sum of digits <= 7
My code is below:
Function NumOps(Curr_ConFig As Variant, ListOfOptions As Range)
Dim Array1 As Variant
Dim i As Long
Dim k As Long
Dim C As Integer
Array1 = ListOfOptions
C = 0
For i = LBound(Array1) To UBound(Array1)
k = i - Curr_ConFig
If k < 0 Then
C = C
ElseIf SumDigits(k) > 7 Then
C = C
Else: C = C + 1
End If
Next i
NumOps = C
End Function
Curr_ConFig is supposed to be cell A1. ListOfOptions is supposed to be a Range of the array in Excel.
Assuming I already create a SumDigits() function successfully.
Could someone point me to the right direction? Thanks
C = Cdoes nothing=COUNTIF(C1:C9,">"&A1). Why use UDF?