What are the fields you want to have as input and variables and what are the expected output fields. I understand the whole add sub dilemma but need to know what you want as input and output.
gowflow
Function QuarterlyBonus(PriorSales As Double, CurrentSales As Double, Quota As Double, SalesBrackets As Range, BonusPercent As Range) As Double
Dim i As Long, j As Long, n As Long
Dim Amount, Bonus As Double, Base As Double, Rate As Double
n = SalesBrackets.Cells.Count
If CurrentSales > Quota Then
Base = PriorSales + Quota
i = Application.Match(Base, SalesBrackets, 1)
For j = i To n
If j < n Then
Amount = Application.Min(SalesBrackets.Cells(j + 1).Value, PriorSales + CurrentSales) - Base
Base = SalesBrackets.Cells(j + 1).Value
Else
Amount = CurrentSales - Base
End If
If Amount > 0 Then Bonus = Bonus + Amount * BonusPercent.Cells(j).Value
Next
End If
QuarterlyBonus = Bonus
End Function
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
adding to,subject,body for the opened mail instead of creating new mail | 15 | 33 | |
DBF to ... Converter | 5 | 45 | |
VBA Array, write each column's start position into an array | 17 | 36 | |
Help with Excel formula | 6 | 38 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
22 Experts available now in Live!