Solved

Function to automate calculation of sheet

Posted on 2011-09-20
6
193 Views
Last Modified: 2012-05-12
Hi,

Have attached an example, basically need a function that returns a value based on a start and end date, i.e. Forcast(startdate,enddate,amount, excluded month 1, exc month 2, exc month 3, exc month 4).

In the example you will see in Column D a list of dates that amounts go out on, ie 14th or 28th of month etc.  Next to this in column E is the amount paid on that date.  Now the function will need to work out for each column how many of those payment dates are between the start and end date specified in the function call.

And then times the amount by the number of times that date appears.  It then needs to add this total together, and add in the (amount) figure as above and also the income figure which is calculated by number of FRIDAYS between that date times £565.

If the month is one of the excluded dates then it is not included in the calculation for that period, i.e. if I included 2 and 3 as the excluded months then it would not count these.

Columns F to I values right at the bottom show what should be right if the function is working as planned.

Cheers
Example.xlsx
0
Comment
Question by:StormFusion
  • 3
6 Comments
 

Author Comment

by:StormFusion
ID: 36566187
0
 

Author Comment

by:StormFusion
ID: 36566194
0
 

Author Comment

by:StormFusion
ID: 36572801
Finally found something that has stumped the pro's lol
0
 
LVL 19

Accepted Solution

by:
akoster earned 500 total points
ID: 36708395
Well, it's not hard to concoct a formula that delivers what you are looking for, the hard part is getting to know what exactly you are looking for.
The way i understand the description from an input viewpoint, you could be looking for a formula with 37 inputs (start date, end date, income plus 17 day values and 17 amounts) that has one output.
looking at the expected output columns F:I, you would be looking for a formula that takes the start date, end date, a single day number and a single corresponding day value as inputs and delivers a single output (thereby forgetting about the income on fridays)

If you want a function to represent the formula you are already using, it would be

Public Function Forcast(startdate As Date, enddate As Date, day As Integer, amount As Double) As String
Dim result As Double
Dim wage As Double

    '-- initialise
    result = 0
    wage = 565
        
    For d = startdate To enddate
        '-- add planned dates
        If DatePart("d", d) = day Then result = result + amount
        '-- add income on fridays
        'If Weekday(d, vbMonday) = 5 Then result = result + wage
    Next d
    process = result

End Function

Open in new window


you can un-comment the if weekday()=5 line to include wages on friday.
0
 
LVL 50

Expert Comment

by:teylyn
ID: 37412247
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro 6 45
Excel 2016 Not Responding Issues 6 22
sql server query from excel 3 56
Simple Excel re-arrange data.  (I can work in access too). 8 46
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now