Very tough - storage fee calculation

sony

Board Regular
Joined
Jun 15, 2002
Messages
126
dear pls see the table

Only useful columns for calculation are only:
Column F : Date-in
Column G : Date-out
Column L : Volume out (cbm)

Charging Period : 21st to 20th of every month

I wonder if VBA codes can help calculate storage fee for each charging period and put in the Column M & N, O..n Etc I produce the idea result in the column M, N in red colour for the amount. you can refer to

charging formula is
US$ 3 X VolumeOut (cbm) X Storage days
(Storage Days = Date-out Less Date-In)


the difficult tings are
1) there can be many date-out records for each Date-in shipment. e.g. look at D8749, D8752 they are two deliery out for the shipemnts)

2) If the storage period cross many charging period, excel will auto put the amt in column O, P, R, S, etc.
INVENTORY REPORT1.xls
DEFGHIJKLMN
8PO#(SR#)/DOno.VendornameDateQuantity(PC)Volume(CBM)
9InOutInOutBalanceInOutJuneCharges21stJuneto20thJuly)JulyCharges21stJulyto20thAug)
10
1100002425(AF27FI04)ZDL7/15/20027200720050
12D87498/19/2002360025$375$2250
13D87529/5/2002360025$375$2250
14
1500002425(AF27FI04)ZDL7/16/20027245724553.47
16D87498/2/20027245053.47
17
1800002425(AF27FI04)ZDL7/17/20026809680950.67
19D87498/2/20026809053.47
20
2100002426(AF27FG08)ZDL7/18/2002126001260050.96
22D87498/2/200212600050.96
23
2400002426(AF27FG08)ZDL7/23/20027000700027.89
25D87498/2/20027000027.89
26
AUG
 
tusharm, for your information,
storage-fee.xls
ABCDEFG
1startperiod21-Jun-0221-Jul-0221-Aug-0221-Sep-02
2in-dateou-dateendperiod20-Jul-0220-Aug-0220-Sep-0220-Oct-02
315-Jul-0225-Sep-02530305
Sheet1
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
tusharm, for your information,
storage-fee.xls
ABCDEFG
1startperiod21-Jun-0221-Jul-0221-Aug-0221-Sep-02
2in-dateou-dateendperiod20-Jul-0220-Aug-0220-Sep-0220-Oct-02
315-Jul-0225-Sep-02530305
Sheet1
 
Upvote 0
tusharm, for your information,
storage-fee.xls
ABCDEFG
1startperiod21-Jun-0221-Jul-0221-Aug-0221-Sep-02
2in-dateou-dateendperiod20-Jul-0220-Aug-0220-Sep-0220-Oct-02
315-Jul-0225-Sep-02530305
Sheet1
 
Upvote 0
Yes, you are right. I only addressed your first example. Sorry about that.

Let's start from the beginning. There are five possibilities in comparing the storage period (SP) with the billing period (BP).
The SP is completely inside the BP.
The BP is completely inside the SP.
The SP overlaps the first part of the BP.
The SP overlaps the latter part of the BP.
The SP and the BP don't have anything to do with each other.
We also have to cater to the possibility that no out-date is available.
So, we need four terms in the MIN statement to cater to the first 4 possibilities and an IF clause to deal with the last two.

Add
out-date - period-start-date
for the condition I missed.

So, you really need
=IF(OR(Out="",Out<PStart,In>PEnd),0,1+MIN(PEnd-PStart,Out-PStart,Out-(In+1),PEnd-(In+1))) * out-CBM * daily-rate-per-CBM.

I defined those names (Insert | Name > Define...) using a combination of relative and absolute addresses. See the next post for a HTMLMaker version of the spreadsheet.

The 1+ and the In+1 adjust for what I *believe* -- based on your example -- to be how you calculate the number of days.

This covers all of the possibilities -- I think.

_________________
Regards,

Tushar
www.tushar-mehta.com
This message was edited by tusharm on 2002-08-14 08:12
 
Upvote 0
Book1
ABCDEFGH
1InOutCBMPstart$/cbm/day3
221-Jun21-Jul
320-Jul20-Aug
415-Jul19-Aug25530In=Sheet2!$A4
515-Jul05-Sep25531Out=Sheet2!$B5
601-Jul03-Jul20PEnd=Sheet2!G$3
710-May20-Jun00PStart=Sheet2!G$2
823-Jul02-Aug53010AbovenamesarevalidwhenG4
9istheactivecell
Sheet2
 
Upvote 0

Forum statistics

Threads
1,216,503
Messages
6,131,020
Members
449,615
Latest member
Nic0la

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