Simulate Reoccuring Buys

prosyp

New Member
Joined
Feb 28, 2018
Messages
1
Hi!

So far I was just a still follower, now i have problem where my mind currently is blocked. What I want to do:

I'm building currently a business case for our startup. My timescale is monthly (C2 = Jan2018, D2 = Feb 2018.... What i need to simulate is:


  • If we onboard a new customer in Jan18 he will do one purchase in Jan2018 (C3 =1)
  • But he will also do purchases later in the processs
  • This LATER should be definied as variables in the model that can be changed easily.
  • The variables are:
  • -- Number of total buys (e. g. 10)
  • -- Number of month between the buys (e.g 2 month between all the buys
  • So following this logic every 2 third month should be one additionl buy from an existing customer (e. g. in Cell e4,h4,...)

Does anyone have an idea how to model that using formulars?

THanks!

Best regards,

Sebastian
 

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.
A screenshot of what the result should look like would be helpful. From what I understand though, depending on the variable values this table will vary in size so I would just have a macro create it. Are you just trying to put a 1 under each month a purchase is made and each row represents a customer?

Code:
Sub ListPurchases()
    Dim totalBuys As Long, monthsBetween As Long, totalMonths As Long, i As Long, monthsWaited As Long
    Dim d As Date

    d = DateValue("Jan 1, 2018")
    totalBuys = Range("A1")
    monthsBetween = Range("A2")
    monthsWaited = monthsBetween [COLOR=#008000]'set this so the first loop sets a purchase, see logic below inside For loop[/COLOR]
    totalMonths = totalBuys + monthsBetween * (totalBuys - 1)

    For i = 1 To totalMonths
        d = DateAdd("m", i - 1, d)
        Cells(2, 2 + i) = d 'list months on row 2 starting at C

        If monthsWaited = monthsBetween Then [COLOR=#008000]'whenever the months waited equals the months between, it means to list a purchase on row 3
[/COLOR]            monthsWaited = 0 [COLOR=#008000]'reset months waited[/COLOR]
            Cells(3, 2 + i) = 1 [COLOR=#008000]'list purchase[/COLOR]
        Else
            monthsWaited = monthsWaited + 1 [COLOR=#008000]'increment months waited by 1 month[/COLOR]
            Cells(3, 2 + i) = 0 [COLOR=#008000]'no purchase listed[/COLOR]
        End If
    Next i
End Sub

it is a rough draft and untested but it seems to follow the logic you described. You can modify this to suit your needs or maybe get an idea from it.

this would take the input variables from A1 and A2 and generate a table of purchases on rows 2 and 3, starting at column C
 
Last edited:
Upvote 0
How about a formula?

[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][td="bgcolor:#C0C0C0"]
C​
[/td][td="bgcolor:#C0C0C0"]
D​
[/td][td="bgcolor:#C0C0C0"]
E​
[/td][td="bgcolor:#C0C0C0"]
F​
[/td][td="bgcolor:#C0C0C0"]
G​
[/td][td="bgcolor:#C0C0C0"]
H​
[/td][td="bgcolor:#C0C0C0"]
I​
[/td][td="bgcolor:#C0C0C0"]
J​
[/td][td="bgcolor:#C0C0C0"]
K​
[/td][td="bgcolor:#C0C0C0"]
L​
[/td][td="bgcolor:#C0C0C0"]
M​
[/td][td="bgcolor:#C0C0C0"]
N​
[/td][td="bgcolor:#C0C0C0"]
O​
[/td][td="bgcolor:#C0C0C0"]
P​
[/td][td="bgcolor:#C0C0C0"]
Q​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
1​
[/td][td="bgcolor:#F3F3F3"]
Customer
[/td][td="bgcolor:#F3F3F3"]
Qty
[/td][td="bgcolor:#F3F3F3"]
Interval
[/td][td="bgcolor:#F3F3F3"]
Start
[/td][td]DoNotUse[/td][td]
Jan-18​
[/td][td]
Feb-18​
[/td][td]
Mar-18​
[/td][td]
Apr-18​
[/td][td]
May-18​
[/td][td]
Jun-18​
[/td][td]
Jul-18​
[/td][td]
Aug-18​
[/td][td]
Sep-18​
[/td][td]
Oct-18​
[/td][td]
Nov-18​
[/td][td]
Dec-18​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]Alan[/td][td]
5​
[/td][td]
2​
[/td][td]
Jan-18​
[/td][td][/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td]Barb[/td][td]
3​
[/td][td]
3​
[/td][td]
Feb-18​
[/td][td][/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td]Cain[/td][td]
2​
[/td][td]
4​
[/td][td]
Mar-18​
[/td][td][/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
1​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][/tr]
[/table]


In F2 and copied across and down,

=IF(F$1 < $D2, 0, --AND(SUM($E2:E2) < $B2, MOD(DATEDIF($D2, F$1, "m"), $C2) = 0))
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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