HeloNatebour
03-16-2019, 12:42 AM
Hi im learning how to program in VBA and i have a problem with this code...
I need to count the even number of X random Cells then have to do an average of this numbers. My problem is, how count all even numbers to divide it by the sum of all.
Here is my code....
Sub Numbers()
Dim row, op, add As Integer
row = 1
For coun = 1 To 5
op = Cells(row, 1).Value Mod 2
If op = 1 Then
add = Cells(row, 1).Value + next
ElseIf op = 0 Then
addim = Cells(row, 1).Value + next2
End If
next2 = addim
next = add
row = row + 1
avg = addim / **** < Here is my problem, how can i count all the even numbers in the loop to divide by, in the expresion?
Next
Range("C1").Value = add
Range("D1").Value = avg
End Sub
Thanks in advance
I need to count the even number of X random Cells then have to do an average of this numbers. My problem is, how count all even numbers to divide it by the sum of all.
Here is my code....
Sub Numbers()
Dim row, op, add As Integer
row = 1
For coun = 1 To 5
op = Cells(row, 1).Value Mod 2
If op = 1 Then
add = Cells(row, 1).Value + next
ElseIf op = 0 Then
addim = Cells(row, 1).Value + next2
End If
next2 = addim
next = add
row = row + 1
avg = addim / **** < Here is my problem, how can i count all the even numbers in the loop to divide by, in the expresion?
Next
Range("C1").Value = add
Range("D1").Value = avg
End Sub
Thanks in advance