Reputation: 147
I need to write some code that compares dates in an excel file and then high lights those rows of data based on the data evaluations. Essentially there are 3 columns in this file that have a standard Month/day/year format. I need to compare the day of all three columns to see if they are within a 3 day date difference "don't care about the month". If they are not within the 3 day date difference I want to high light them. An example of an OK comparison would be (10/1/2015,12/2/2015, 8/3/2015) I would not want to do anything with this row of data. Here is what I consider to be a "bad" date comparison (10/1/15, 11/3/2015, 8/5/2015). All the dates have to be within 3 days and as you can see there is a 4 day date difference between 10/1 and 8/5. How can I write something up like this to evaluate this?
Upvotes: 0
Views: 47
Reputation: 96753
You can just compare the Max() of the days to the Min() of the days with the Array Formula:
=IF(MAX(DAY(A1:C1))-MIN(DAY(A1:C1))>3,"fail","Close enough")
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
You can do the same functionality with VBA if that is needed.
Upvotes: 2