Chintsapete
Registered User.
- Local time
- Today, 23:55
- Joined
- Jun 15, 2012
- Messages
- 137
Noted, I'm a bit under time pressure and I can tweak it once I got the formula right. I did see one or two things to improve the last posting in that respect.
I did realize after that there is still one factor missing.
I did fiddle another section in, but it doesn't seem to run.
What should happen is: SumOfGross is between 2000 and 4000 and SumOfDaysWorked is less then mydaysinperiod then it should use (ETI1*(SumOfDaysworked/mydaysinperiod))
Is the code getting confused because I repeat the <4000 in my solution below?
I tried all sorts of variations but don't seem to come right. The logic in my head is really not quite with it, I'm afraid.
I really appreciate the time you spend to explain.
I did realize after that there is still one factor missing.
I did fiddle another section in, but it doesn't seem to run.
What should happen is: SumOfGross is between 2000 and 4000 and SumOfDaysWorked is less then mydaysinperiod then it should use (ETI1*(SumOfDaysworked/mydaysinperiod))
Is the code getting confused because I repeat the <4000 in my solution below?
I tried all sorts of variations but don't seem to come right. The logic in my head is really not quite with it, I'm afraid.
I really appreciate the time you spend to explain.
Code:
Public Function fnETI1(SumOfGross As Double _
, ETI1 As Integer _
, SumOfDaysWorked As Integer _
, FromDate As Date _
, ToDate As Date _
) As Double
Dim myFactor As Double
Dim Mydaysinperiod As Integer
myFactor = 0.5
If ETI1 = 500 Then myFactor = 0.25
If SumOfGross < 0 Then
fnETI1 = 0
ElseIf SumOfGross < 2000 Then
Mydaysinperiod = DateDiff("ww", FromDate, ToDate, 6)
fnETI1 = [SumOfGross] * ([SumOfDaysWorked] / (Mydaysinperiod * 5) * myFactor)
ElseIf SumOfGross < 4000 And (Mydaysinperiod * 5) > [SumOfDaysWorked] Then
Mydaysinperiod = DateDiff("ww", FromDate, ToDate, 6)
fnETI1 = [ETI1] * ([SumOfDaysWorked] / (Mydaysinperiod * 5))
ElseIf SumOfGross < 4000 Then
Mydaysinperiod = DateDiff("ww", FromDate, ToDate, 6)
fnETI1 = [SumOfGross] * ([SumOfDaysWorked] / (Mydaysinperiod * 5) * myFactor)
ElseIf SumOfGross < 6000 Then
fnETI1 = ETI1 - (myFactor * ([SumOfGross] - 4000))
Else
fnETI1 = 0
End If
If fnETI1 > 1000 Then fnETI1 = ETI1
End Function