+ Reply to Thread
Results 1 to 8 of 8

Need macro to calculate number of days elapsed between data in two columns

  1. #1
    Registered User
    Join Date
    10-22-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2003
    Posts
    5

    Need macro to calculate number of days elapsed between data in two columns

    Hi all,

    I am creating a macro to work with an excel file that will be downloaded monthly from an online database.

    This portion of the macro will deal with two columns (which are already created in the Excelsheet) described below:

    a) Headed "todaydate"; always in column x; range: x2:x300; will be populated with today's date (mm/dd/yyyy)

    b) Headed "createdate"; column location varies; range: _2:_300; will be populated with the data's create date (mm/dd/yyyy)

    I need the macro to calculate the number of days elapsed between createdate and todaydate within each row and highlight the entire row when the number of elapsed days is greater than 60.

    Though I understand the basics behind finding a column based on the header value, subtracting cell values from each other, and highlighting rows, I am having difficulty putting all these concepts together for the macro. I have searched this forum and Google more generally for a solution to the problem to no avail.

    Thanks so much for the help.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need macro to calculate number of days elapsed between data in two columns

    Hi

    This is wrong.

    All you need is a conditional format.

  3. #3
    Registered User
    Join Date
    10-22-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Need macro to calculate number of days elapsed between data in two columns

    Hi,

    I am leaving my department in a few months and someone else will need to download and analyze the data. Though I am not highly skilled in Excel, the others in my department are basically computer illiterate. I am already making a macro for other parts of the analysis, and want to make the process as easy and sustainable as possible for after I leave. Thus, I would prefer to incorporate this aspect of the processing into my macro rather than teach the others in my department how to use conditional formatting and run a macro simultaneously.

    Thanks

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need macro to calculate number of days elapsed between data in two columns

    All I did here was to select all the cells

    Select the home tab and then conditional format

    Insert new rule

    Format determined by formula

    Then I entered this formula:-

    Please Login or Register  to view this content.
    Then I selected my format to FILL with Red.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-22-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Need macro to calculate number of days elapsed between data in two columns

    Thanks so much for the help but I need a macro. See above.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need macro to calculate number of days elapsed between data in two columns

    Now If you want to do that using a macro

    Try this code:-

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-22-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Need macro to calculate number of days elapsed between data in two columns

    As I mentioned above, the column "createdate" will not always start in the same location (e.g. B1), but rather will change depending on how the user downloads the data from the online database. Dealing with this issue is what I am most confused about. The column "todaydate", however, will always start in X1. Your code assumes the columns exist in B and A.

    Does anyone know how to address this issue? Thanks

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need macro to calculate number of days elapsed between data in two columns

    modify the code to look for "CreateDate" and use that to build the formula.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 10-23-2013 at 07:37 PM.

+ 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] Adding Total Number of Days Elapsed and Displaying >31 Days
    By cwwazy in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-03-2013, 08:18 AM
  2. How to calculate elapsed time between to days excluding weekends.
    By Mush001 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-23-2009, 04:19 PM
  3. How to Calculate Days elapsed where Weekend is calculated as 1 Working Day?
    By speakbones in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-14-2007, 07:20 PM
  4. Calculate elapsed working days
    By RUSH2CROCHET in forum Excel General
    Replies: 6
    Last Post: 03-09-2006, 04:40 PM
  5. formula for tracking number of elapsed days from a stard date
    By spm1371 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-22-2006, 01:00 AM

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