Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with code please
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with code please
Your address is not valid. Otto
"Otto Moehrbach" wrote in message ... 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with code please
sorry, deleted that account a few weeks ago.....
please try: but removing the "not" after family. "Otto Moehrbach" wrote in message ... Your address is not valid. Otto "Otto Moehrbach" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming | |||
option buttons run Click code when value is changed via VBA code | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming |