helix123
09-27-2012, 03:40 PM
Hi,
I'm trying to learn vba and have a problem which I would like to use a user defined function for in excel.
What I want to be able to do is input the value of a budget (say $30,000) and then subtract off each weekly cost (which varies week to week) until the budget runs out and then have a counter which counts the number of iterations/loops that the initial budget lasted for given that it started from a particular week.
In the first column I have which week it is i.e. week1, week2, week3 etc..
In the second column I have the total cost associated with each particular week i.e. for week1 the total cost is $502 for week2 it is $508 etc.. (see attached file)
Ideally it would be good to have a function where the first argument is the budget amount and the second argument would be the start week. For example starting the iterations on week2 the first iteration would be $30000-$508.
The end goal is to have the number of weeks a particular budget amount will last before reaching zero starting from any given week.
Hope this makes sense.
I know how to get an answer using excel formulas but it would be good to learn how to do this with vba..
Thanks in advance.
I'm trying to learn vba and have a problem which I would like to use a user defined function for in excel.
What I want to be able to do is input the value of a budget (say $30,000) and then subtract off each weekly cost (which varies week to week) until the budget runs out and then have a counter which counts the number of iterations/loops that the initial budget lasted for given that it started from a particular week.
In the first column I have which week it is i.e. week1, week2, week3 etc..
In the second column I have the total cost associated with each particular week i.e. for week1 the total cost is $502 for week2 it is $508 etc.. (see attached file)
Ideally it would be good to have a function where the first argument is the budget amount and the second argument would be the start week. For example starting the iterations on week2 the first iteration would be $30000-$508.
The end goal is to have the number of weeks a particular budget amount will last before reaching zero starting from any given week.
Hope this makes sense.
I know how to get an answer using excel formulas but it would be good to learn how to do this with vba..
Thanks in advance.