Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function ProjectSales(forMonth As Date, salesLastMonth As Integer, salesLastMonthYear As Integer, salesCurrentMonthYear As Integer) As Double
- Dim DC As Integer ' days in the current month
- Dim DL As Integer ' days in last month
- Dim DLY As Integer ' days in last month one year ago
- Dim DCY As Integer ' days in the current month one year ago
- DC = DaysInMonth(forMonth)
- DL = DaysInMonth(DateAdd("m", -1, forMonth))
- DLY = DaysInMonth(DateAdd("m", -13, forMonth))
- DCY = DaysInMonth(DateAdd("m", -12, forMonth))
- Dim SL As Integer ' sales in the last month
- Dim SLY As Integer ' sales in the last month one year ago
- Dim SCY As Integer ' sales in the current month one year ago
- SL = salesLastMonth
- SLY = salesLastMonthYear
- SCY = salesCurrentMonthYear
- Dim m As Double ' slope of the sales rate from the months last year
- m = ((SCY / DCY) - (SLY / DLY)) / ((DCY + DLY) / 2)
- ' our x = 0 is halfway through the last month. Find the dates of the start and end of the current month based on our x
- Dim monthStart As Double
- Dim monthEnd As Double
- monthStart = DL / 2
- monthEnd = monthStart + DC
- ProjectSales = m * (monthEnd ^ 2 / 2) + (SL / DL) * monthEnd - (m * (monthStart ^ 2 / 2) + (SL / DL) * monthStart)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement