LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Comparing Dates

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing dates Gareth.Evans Excel Worksheet Functions 0 March 26th 09 08:54 AM
Comparing Dates fubdap Excel Discussion (Misc queries) 3 September 27th 07 03:53 PM
Comparing two dates using between. BerkshireGuy Excel Programming 1 April 24th 07 12:47 AM
Comparing 3 dates Steve Excel Worksheet Functions 1 May 9th 06 12:10 PM
comparing dates Myriam Excel Programming 3 October 11th 04 04:49 AM


All times are GMT +1. The time now is 02:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"