Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I realised in the middle of the night that the order of dates mattered in my
first lot of code. Here is a version where the order does not matter: Sub Test() If Abs(Cells(2, 2).Value - Cells(2, 1).Value) <= 7 Then Cells(2, 3).Value = "Within tolerance" Else Cells(2, 3).Value = "Different" End If End Sub "JT" wrote: Sorry for the previous post with no info. I'm comparing data on 2 different sheets in a workbook. To do this, I create a reference field based on fields appearing on both sheets. Originally the reference fields contained a cost center, month, day, and amount. The items from each sheet had to match exactly. On one sheet the date appears as mm/dd/yyyy. On the other sheet, the data appears as mm/dd. Originally, I stripped out the month and day from both sheets and made a string from these fields after ensuring the length of both were 2 characters. This worked well. Now however, I need to change it so the user can enter a number of tolerance days. If the date on sheet1 is equal to or greater than the date on sheet2 by the number of tolerance days, it is a match. I want to set a variable for the date (month and day) on sheet2 and compare it to a variable for the date on sheet1. I'm having trouble getting started since the date on sheet 2 is only month and day. I'm not sure how to handle it when the date on sheet2 is the end of one month and the date on sheet1 is one of the first few days in the next month. Is there some way to compare the month and day and calculate the difference between another month and day? Thanks. Any help getting started would be greatly appreciated......... -- JT |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Comparing dates | Excel Worksheet Functions | |||
Comparing Dates | Excel Discussion (Misc queries) | |||
Comparing two dates using between. | Excel Programming | |||
Comparing 3 dates | Excel Worksheet Functions | |||
comparing dates | Excel Programming |