+ Reply to Thread
Results 1 to 3 of 3

DateAdd/DateDiff problem

  1. #1
    Registered User
    Join Date
    11-25-2013
    Location
    52899945
    MS-Off Ver
    ms office 2013
    Posts
    2

    DateAdd/DateDiff problem

    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

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: DateAdd/DateDiff problem

    Try something like:

    Please Login or Register  to view this content.
    Last edited by Olly; 11-25-2013 at 04:58 AM.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    11-25-2013
    Location
    52899945
    MS-Off Ver
    ms office 2013
    Posts
    2

    Re: DateAdd/DateDiff problem

    Thank you so much, will try it.

    Best rgrds,

    Patrik

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Dateadd issue when adding weeks to a date
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2013, 10:01 AM
  2. [SOLVED] dateAdd Overflow
    By rmweaver81 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2013, 01:15 PM
  3. [SOLVED] DateDiff Problem
    By Desirees007 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2012, 04:16 AM
  4. DateAdd problem
    By si666 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2011, 06:58 AM
  5. DateAdd
    By johnboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2006, 06:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1