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.

[TABLE="width: 800"]
<tbody>[TR]
[TD]Customer[/TD]
[TD]Starting date[/TD]
[TD]Ending date[/TD]
[TD]Total amount[/TD]
[TD]jan-18[/TD]
[TD]feb-18[/TD]
[TD]mar-18[/TD]
[/TR]
[TR]
[TD]Customer A[/TD]
[TD]01-01-2018[/TD]
[TD]31-12-2018[/TD]
[TD]120000[/TD]
[TD]10000[/TD]
[TD]10000[/TD]
[TD]10000[/TD]
[/TR]
[TR]
[TD]Customer B[/TD]
[TD]01-02-2018[/TD]
[TD]31-03-2018[/TD]
[TD]10000[/TD]
[TD]0[/TD]
[TD]5000[/TD]
[TD]5000[/TD]
[/TR]
[TR]
[TD]Customer C[/TD]
[TD]01-09-2017[/TD]
[TD]28-02-2018[/TD]
[TD]60000[/TD]
[TD]10000[/TD]
[TD]10000[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]

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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

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,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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