Hello,
Trying to build a counter function I will be using in a loop to check for 4 different requirements and check you at least have 3 of those requirements or how many you attained. As you can see in my code below the x variable will be the variable I'm using in my For Loop so I can use the code with each row in my list. Then I need to return the value of Count and set it to another variable called MileCount outside of the function. Can't figure out what's the equivalent of a return statement in VBA. Can someone help me out on this one?
Trying to build a counter function I will be using in a loop to check for 4 different requirements and check you at least have 3 of those requirements or how many you attained. As you can see in my code below the x variable will be the variable I'm using in my For Loop so I can use the code with each row in my list. Then I need to return the value of Count and set it to another variable called MileCount outside of the function. Can't figure out what's the equivalent of a return statement in VBA. Can someone help me out on this one?
VBA Code:
Dim MileCount as Integer
MileCount = MileCounter()
Function MileCounter(x) As Integer
Dim Count As Integer
Count = 0
'D Milestones
If Sheets("Attainment").Cells(x, 9).Value >= DMile1Req Then
Count = Count + 1
End If
If Sheets("Attainment").Cells(x, 11).Value >= DMile2Req Then
Count = Count + 1
End If
'F Milestones
If Sheets("Attainment").Cells(x, 21).Value >= FMile1Req Then
Count = Count + 1
End If
If Sheets("Attainment").Cells(x, 23).Value >= FMile2Req Then
Count = Count + 1
End If
return Count
Exit Function
End Function