+ Reply to Thread
Results 1 to 3 of 3

Checking to see if a date is within current month from a column of date values using vba

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Checking to see if a date is within current month from a column of date values using vba

    Hi,

    I have a date input by the user......call-it "currentdate".

    I want to compare this "currentdate" to a column of dates (say colA) in the following manner.
    We would make this comparison to EACH date in column-A.


    If month of current date = month of date in col-A AND year of currentdate = year of date in col-A then assign value of "valid" to an array.

    This comparison ensures that the date in column A is in the same month if you will as the "currentdate"

    I tried the month and year functions but if the value in col-A is not a date then i get a runtime error.

    any ideas?

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Checking to see if a date is within current month from a column of date values using v

    Hi,

    Why don't you check the contents of the cell is a date or not.

    Use the Isdate() function , it returns true or false.

    Hope this helps.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Checking to see if a date is within current month from a column of date values using v

    your correct.........i will have to use that function "isdate".

    What i decided to do is take the user input date and create two new dates based on the user date: The first-of-th-month and end-of-month dates. THen take dates from col-A and make sure its between the first and end of months.

    but i will still probably have to use the "isdate" function to make sure the value in col-a is not blank or something other than a date.

    thanks.

+ 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