Dividing total revenue over several months

keizerkarel

New Member
Joined
Jun 25, 2018
Messages
2
I have invoices with a certain total amount that I want to spread on a timeline per month. Example:
*Date formatting is the standard here. Feel free to swap it around.

CustomerStarting dateEnding dateTotal amountjan-18feb-18mar-18
Customer A01-01-201831-12-2018120000100001000010000
Customer B01-02-201831-03-201810000050005000
Customer C01-09-201728-02-20186000010000100000

<tbody>
</tbody>

Is there a way to use the total amount + license period to autofill the chart on the right?
- Every month is equal, regardless of amount of days.
- All invoices run in full months from the first day to the last day.
- Invoices can be anywhere between 1 and 24 months.

I'm in doubt whether the above is possible without macro's. My own googling however returned nothing, neither VBA nor excel, that came remotely close.

Anyone who can point me in the right direction?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Excel 2010
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1CustomerStarting dateEnding dateTotal amountJan-17Feb-17Mar-17Apr-17May-17Jun-17Jul-17Aug-17Sep-17Oct-17Nov-17Dec-17Jan-18Feb-18Mar-18Apr-18May-18Jun-18Jul-18Aug-18Sep-18Oct-18Nov-18Dec-18
2Customer A1/1/201812/31/2018120000 10000.0010000.0010000.0010000.0010000.0010000.0010000.0010000.0010000.0010000.0010000.0010000.00
3Customer B2/1/20183/31/2018100005000.005000.00
4Customer C9/1/20172/28/20186000010000.0010000.0010000.0010000.0010000.0010000.00
Sheet7
Cell Formulas
RangeFormula
E2=IF(AND(E$1>=$B2,E$1<=$C2),$D2/(1+DATEDIF($B2,$C2,"m")),"")
 
Last edited:
Upvote 0
Try the following macro:
Code:
Sub DivideRevenue()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim lColumn As Long
    lColumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
    Dim rDate As Range, rDate2 As Range
    For Each rDate2 In Range("B2:B" & LastRow)
        For Each rDate In Range(Cells(1, 5), Cells(1, lColumn))
            If rDate >= rDate2 And rDate <= rDate2.Offset(0, 1) Then
                Cells(rDate2.Row, rDate.Column) = Range("D" & rDate2.Row) / Abs(Month(Range("C" & rDate2.Row)) - Month(Range("B" & rDate2.Row)) + 1)
            Else
                Cells(rDate2.Row, rDate.Column) = 0
            End If
        Next rDate
    Next rDate2
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,353
Messages
6,124,458
Members
449,161
Latest member
NHOJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top