View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default help with code please

The following macro does what you want. You said "within 6 days". That
means <=6 days on either side of the Column J date. IOW, the absolute value
of the difference is <=6 days and both dates get copied to Columns C & D.
I am also sending you a small file with this macro placed in the proper
module. I am sending this file to . If this
is not a good address for you and you feel you need further help with this,
please post back. HTH Otto
Sub GetDates()
Dim RngJ As Range
Dim RngK As Range
Dim j As Range
Dim k As Range
Dim Dest As Range
Set Dest = [C2]
Set RngJ = Range("J2", Range("J" & Rows.Count).End(xlUp))
Set RngK = Range("K2", Range("K" & Rows.Count).End(xlUp))
For Each j In RngJ
For Each k In RngK
If Abs(j - k) <= 6 Then
Dest = j
Dest.Offset(, 1) = k
Set Dest = Dest.Offset(1)
End If
Next k
Next j
End Sub
"Gareth" wrote in message
...
I have a dates in column J and also dates in column K

What I want to do is check each date in column J to make sure there are no
dates in column K that are within 6 days of it.

That is:
J2=01/04/2005
no date in column K can be <07/04/2005

If there are any then possibly create a list of C2 and the C column values
for the records within 6 days.

Hope this makes sense.

Thanks in advance.

Gareth