Hello everyone,
My experience with VBA is very limited but I hope you guys could bring some light upon my problem.
I've got a sheet named "rental contracts". This sheet contains several rental agreements and lease contracts.
In column "F", I have the original expiry date for each contract in format "yyyy-mm-dd".
In column "I" I have a extension-factor in #months.
To the problem:
I want to calculate how many Days until the expiry date of each contract. I use dateDiff, which works perfectly for all contracts who have expiry date that arent due yet. The problem is that some of the conracts expiry dates are due, but still active. For example if my Company doesn't cancel a lease before the notice-period deadline, the expiry date automatically gets extended with 12 months.
I want to code a loop that checks column "F" for the original expiry date. If org. exp. date > NOW then checks column "I" for the months to use in the DateAdd function and puts the updated expiry date in column "K".
Example:-------------------- F ----------------------------------------------I------------------------K
ContractA--------------2012-06-01-----------------------------------------6-------------------Up-dated date
For this contract the code should add 6 months (from column "I") and do until the expiry date>Now and put the new value in the column k (same row). In this case I need to add 6+6+6 and get the new expiry date "2013-12-01". I need to repeat this procedure for each contract (each row).
I have no usefull code to give you and no excel-sheet. I understand that my description of the problem is quite cloudy, but any help would be most appreciated.
Best regards,
Patrik
Bookmarks