here is what I'm ultimately trying to do...

I'm trying to write a VBA function that will populate a weekly cashflow with different monthly payments. I have columns of information on the left and a calendar laid out across the top rows (row 1 is a week number [WeekNumber] of my calendar [1, 2, 3, etc.] and row 2 is the week ending date [mm/dd/yyyy] [Date]). in my columns to the left I have information corresponding to the week of the cashflow on which the payment should start (StartWeek), then a column for the week of the cashflow on which the payment should end (StopWeek), and a column for the amount of the payment (Rate).

Then I have a blank matrix that I want to populate with payment amounts on the weeks in which they belong, and zero where no payment is necessary. I'm looking for a (formula or function or macro??) that can First:

Evaluate the first week in which the payment is due (ie, I'm in cell G10. StartWeek in cell A10 equals 5. WeekNumber in G1 is 4, therefor enter "0" in G10. When I paste the same formula in H10, A10 still equals 5, and H1 equals 5 as well, so enter Rate in H10.)

That's the first part. Then...

I want to make the recurring payment in the same week of the month, for all subsequent months, until the payment is supposed to stop. (ie, the Date in H10 was 7/13/2008, so for this particular payment, I want to enter a Rate in the cashflow every time I hit the 2nd week of each subsequent month - I10 corresponds to 7/20 - do nothing, J10 corresponds to 7/27 - do nothing, K10 corresponds to 8/3 - do nothing, L10 corresponds to 8/10 [2nd wk of the month!!] - Enter Rate).

Then this would go on until it reaches a column where StopWeek = WeekNumber, in which case it would enter the last payment (if the column corresponds to the appropriate week of the month as determined by initial StartWeek) then begin to return "0" for any WeekNumber > StopWeek, or just return "0" if StopWeek=WeekNumber but Date is not the proper week of the month for a payment, and "0" thereafter.

does that make sense and is any of this possible? Or is there an easier way to accomplish what I'm trying to do?

Thanks!