Identifying a variety of holidays in a data set

  • While searching the internet, I came across the following code, which searches a data set for the macro-defined search terms, and copies them into a separate workbook. This code works splendidly, however, I would like to modify it to search for certain holidays. However, I have never worked with these types of date-defining/constricting codes before. In a simple example, how might I modify this code to search for January 1, December 24, and December 25... instead of Fruit 2, Fruit 5, and Fruit 18?


    Thank you in advance for your help!


  • Re: Identifying a variety of holidays in a data set


    If you just want to modify the existing code, then change the data type:



    Otherwise there are better ways to do this kind of thing.

  • Re: Identifying a variety of holidays in a data set


    Thank you for your quick response!


    This is certainly one way of accomplishing the task, however, I would rather not hard code absolute dates into the macro if I don't have to. I would like to set up the macro to identify "December 25" in ANY year (not just 2015). Could this existing code be modified to achieve this task? The more advanced application would be that I would use the macro to identify a variety of dates (in any year).


    Thank you again!

  • Re: Identifying a variety of holidays in a data set


    I found a solution that will work for me - I did not use the code from my original post. Below is an excerpt of the coding from my Macro (granted, all the variables are not defined in this excerpt). I embedded an IsDate function in an IF statement, to verify that the cell value was a date - if the value is not a date, then the "LSearchRowMod = LSearchRowMod + 1" portion moves the search to the next line. If a date is found and it matches the "month" and "day" criteria, then it is copied into Sheet2. I can then replicate this code for each date that I want to search.


    Thank you again for your help.


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!