+ Reply to Thread
Results 1 to 2 of 2

Date Range Question

  1. #1
    Registered User
    Join Date
    02-15-2007
    Posts
    9

    Date Range Question

    I'm writing a macro to find out if a given month/year falls within a date range.

    The spreadsheet has 2 columns (3 and 4) which hold a start date and stop date. The macro needs to cycle through each month of the year (over 3 years) and count the rows that the given month falls within the date range

    The row gets counted even if it's only for 1 day.
    Example, if start date is 1/31/06, it would still get counted when checking for rows in the month of January 2006, same goes for stop dates.

    This is the code I have now:

    Please Login or Register  to view this content.
    The stop date might be blank (if the job is still outstanding), so I just assigned it todays date since the macro only checks up through the previous month.

    The Month and Year variables are used to place the results in a table correctly.

    I'm wondering if I have my IF statement correct to validate if the date range falls within the given month. I'd try to validate it using just a specific month/year, but there's thousands of rows, so manual counting is not an option and if my IF statement is incorrect, then I can't write macro to check just a single month.

    Maybe there's an easier function that can do this?

    Anyone have any suggestions?

  2. #2
    Registered User
    Join Date
    02-15-2007
    Posts
    9
    Would this work? It checks all 3 senerios, if the start date is within that month or the month range is between the two dates, or the stop date is within the month. All three would be acceptable to count that line.

    Please Login or Register  to view this content.
    I also changed Date1 to be the first day of the month and Date2 to the last day of the month.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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