#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Date Find

Hello,

I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".

The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.

For Each cell1 In rng1

Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)

Next cell1


Regards,

DaveU

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Date Find

Hi Dave. You need to format the find criteria the same as the column of
dates you are looking in so try this.

Dim DateToFind

For Each cell1 In rng1
DateToFind = Format(cell1,"mm/dd/yyyy")
Set Y = rng2.Find(what:=DateToFind, LookIn:=xlValues,
lookat:=xlPart)
Next cell1



"Dave Unger" wrote:

Hello,

I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".

The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.

For Each cell1 In rng1

Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)

Next cell1


Regards,

DaveU


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Date Find

Hi OssieMac

Thanks for your reply. The problem here is the time difference. The
data I'm looking in was entered with date & time and is formatted as
"01/28/2007 04:59:59 PM". The find list contains date only,
"01/28/07", and changing the format results in "01/28/2007 12:00:00
AM". I want the time part disregarded, and have these 2 items 'match'
on the date part.

regards,

Dave.


On Feb 8, 7:59 pm, OssieMac
wrote:
Hi Dave. You need to format the find criteria the same as the column of
dates you are looking in so try this.

Dim DateToFind

For Each cell1 In rng1
DateToFind = Format(cell1,"mm/dd/yyyy")
Set Y = rng2.Find(what:=DateToFind, LookIn:=xlValues,
lookat:=xlPart)
Next cell1



"Dave Unger" wrote:
Hello,


I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".


The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.


For Each cell1 In rng1


Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)


Next cell1


Regards,


DaveU- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Date Find

Sorry Dave. My mistake because I left a line out. However, to pay for my
mistake, I have tested the following and it not only finds the dates but
finds all occurrences if there is more than one match to the date. I actually
formatted them in the test macro and rng1 had no times associated with it
rng2 did have actual times.

Here is a small sample of the data I used:-
rng1 rng2
01/21/2006 01/13/2006 07:19:21
01/22/2006 01/14/2006 13:56:21
01/23/2006 01/15/2006 11:11:54
01/24/2006 01/16/2006 20:53:23
01/25/2006 01/17/2006 20:31:38
02/01/2006 01/18/2006 06:13:58
02/02/2006 01/19/2006 03:44:30
02/03/2006 01/20/2006 07:51:27
02/04/2006 01/21/2006 21:58:02
02/05/2006 01/22/2006 12:29:14
02/10/2006 01/23/2006 16:22:05

Dim DateToFind
Dim NoOfFinds
Dim InitAddress
Dim rng1 As Range
Dim rng2 As Range

Sub Find_Dates()
Sheets("Sheet1").Select
Set rng1 = Range("A2:A74") 'List of dates to find
rng1.Select
Selection.NumberFormat = "mm/dd/yyyy"
Set rng2 = Range("B2:B544")
rng2.Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm:ss" 'List of dates to search
Range("A1").Select
NoOfFinds = 0
For Each cell1 In rng1
DateToFind = Format(cell1, "mm/dd/yyyy")
Application.FindFormat.NumberFormat = "mm/dd/yyyy"
Set Y = rng2.Find(What:=DateToFind, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not Y Is Nothing Then 'Y is Not Nothing indicates found target
InitAddress = Y.Address 'Save the first address
Do 'Look for further occurrences of the find criteria
NoOfFinds = NoOfFinds + 1 'For testing with Msgbox only
Y.Font.ColorIndex = 5 'For testing purposes only
Set Y = rng2.FindNext(Y)
Loop While Not Y Is Nothing And Y.Address < InitAddress
End If
Next cell1
MsgBox "Total Number of finds = " & NoOfFinds 'For testing purposes only
End Sub

Hope this answers your question.

Regards,

OssieMac


"Dave Unger" wrote:

Hi OssieMac

Thanks for your reply. The problem here is the time difference. The
data I'm looking in was entered with date & time and is formatted as
"01/28/2007 04:59:59 PM". The find list contains date only,
"01/28/07", and changing the format results in "01/28/2007 12:00:00
AM". I want the time part disregarded, and have these 2 items 'match'
on the date part.

regards,

Dave.


On Feb 8, 7:59 pm, OssieMac
wrote:
Hi Dave. You need to format the find criteria the same as the column of
dates you are looking in so try this.

Dim DateToFind

For Each cell1 In rng1
DateToFind = Format(cell1,"mm/dd/yyyy")
Set Y = rng2.Find(what:=DateToFind, LookIn:=xlValues,
lookat:=xlPart)
Next cell1



"Dave Unger" wrote:
Hello,


I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".


The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.


For Each cell1 In rng1


Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)


Next cell1


Regards,


DaveU- Hide quoted text -


- Show quoted text -




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Date Find

After thought. Include the following line at end of module.

Application.FindFormat.Clear

Also your code only included a minimum of arguments in the Find method. To
avoid problems, set all these arguments explicitly each time you use this
method because they are saved from previous finds and if you don't reset them
then the code may not work as you expect. Look up "Find Method" in the help
for VBA Editor and click on show all and read Remarks.

"OssieMac" wrote:

Sorry Dave. My mistake because I left a line out. However, to pay for my
mistake, I have tested the following and it not only finds the dates but
finds all occurrences if there is more than one match to the date. I actually
formatted them in the test macro and rng1 had no times associated with it
rng2 did have actual times.

Here is a small sample of the data I used:-
rng1 rng2
01/21/2006 01/13/2006 07:19:21
01/22/2006 01/14/2006 13:56:21
01/23/2006 01/15/2006 11:11:54
01/24/2006 01/16/2006 20:53:23
01/25/2006 01/17/2006 20:31:38
02/01/2006 01/18/2006 06:13:58
02/02/2006 01/19/2006 03:44:30
02/03/2006 01/20/2006 07:51:27
02/04/2006 01/21/2006 21:58:02
02/05/2006 01/22/2006 12:29:14
02/10/2006 01/23/2006 16:22:05

Dim DateToFind
Dim NoOfFinds
Dim InitAddress
Dim rng1 As Range
Dim rng2 As Range

Sub Find_Dates()
Sheets("Sheet1").Select
Set rng1 = Range("A2:A74") 'List of dates to find
rng1.Select
Selection.NumberFormat = "mm/dd/yyyy"
Set rng2 = Range("B2:B544")
rng2.Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm:ss" 'List of dates to search
Range("A1").Select
NoOfFinds = 0
For Each cell1 In rng1
DateToFind = Format(cell1, "mm/dd/yyyy")
Application.FindFormat.NumberFormat = "mm/dd/yyyy"
Set Y = rng2.Find(What:=DateToFind, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not Y Is Nothing Then 'Y is Not Nothing indicates found target
InitAddress = Y.Address 'Save the first address
Do 'Look for further occurrences of the find criteria
NoOfFinds = NoOfFinds + 1 'For testing with Msgbox only
Y.Font.ColorIndex = 5 'For testing purposes only
Set Y = rng2.FindNext(Y)
Loop While Not Y Is Nothing And Y.Address < InitAddress
End If
Next cell1
MsgBox "Total Number of finds = " & NoOfFinds 'For testing purposes only
End Sub

Hope this answers your question.

Regards,

OssieMac


"Dave Unger" wrote:

Hi OssieMac

Thanks for your reply. The problem here is the time difference. The
data I'm looking in was entered with date & time and is formatted as
"01/28/2007 04:59:59 PM". The find list contains date only,
"01/28/07", and changing the format results in "01/28/2007 12:00:00
AM". I want the time part disregarded, and have these 2 items 'match'
on the date part.

regards,

Dave.


On Feb 8, 7:59 pm, OssieMac
wrote:
Hi Dave. You need to format the find criteria the same as the column of
dates you are looking in so try this.

Dim DateToFind

For Each cell1 In rng1
DateToFind = Format(cell1,"mm/dd/yyyy")
Set Y = rng2.Find(what:=DateToFind, LookIn:=xlValues,
lookat:=xlPart)
Next cell1



"Dave Unger" wrote:
Hello,

I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".

The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.

For Each cell1 In rng1

Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)

Next cell1

Regards,

DaveU- Hide quoted text -

- Show quoted text -






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Date Find

Hi OssieMac,

Thanks again. However, you must be using a newer version of Excel,
I'm using 97 and the FindFormat function isn't available. And I am
aware that the Find arguments should be set each time, just wanted to
keep the sample code as 'bare bones' as possible to illustrate my
approach. Appreciate your help.

regards,

Dave





On Feb 10, 5:15 am, OssieMac
wrote:
After thought. Include the following line at end of module.

Application.FindFormat.Clear

Also your code only included a minimum of arguments in the Find method. To
avoid problems, set all these arguments explicitly each time you use this
method because they are saved from previous finds and if you don't reset them
then the code may not work as you expect. Look up "Find Method" in the help
for VBA Editor and click on show all and read Remarks.



"OssieMac" wrote:
Sorry Dave. My mistake because I left a line out. However, to pay for my
mistake, I have tested the following and it not only finds the dates but
finds all occurrences if there is more than one match to the date. I actually
formatted them in the test macro and rng1 had no times associated with it
rng2 did have actual times.


Here is a small sample of the data I used:-
rng1 rng2
01/21/2006 01/13/2006 07:19:21
01/22/2006 01/14/2006 13:56:21
01/23/2006 01/15/2006 11:11:54
01/24/2006 01/16/2006 20:53:23
01/25/2006 01/17/2006 20:31:38
02/01/2006 01/18/2006 06:13:58
02/02/2006 01/19/2006 03:44:30
02/03/2006 01/20/2006 07:51:27
02/04/2006 01/21/2006 21:58:02
02/05/2006 01/22/2006 12:29:14
02/10/2006 01/23/2006 16:22:05


Dim DateToFind
Dim NoOfFinds
Dim InitAddress
Dim rng1 As Range
Dim rng2 As Range


Sub Find_Dates()
Sheets("Sheet1").Select
Set rng1 = Range("A2:A74") 'List of dates to find
rng1.Select
Selection.NumberFormat = "mm/dd/yyyy"
Set rng2 = Range("B2:B544")
rng2.Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm:ss" 'List of dates to search
Range("A1").Select
NoOfFinds = 0
For Each cell1 In rng1
DateToFind = Format(cell1, "mm/dd/yyyy")
Application.FindFormat.NumberFormat = "mm/dd/yyyy"
Set Y = rng2.Find(What:=DateToFind, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not Y Is Nothing Then 'Y is Not Nothing indicates found target
InitAddress = Y.Address 'Save the first address
Do 'Look for further occurrences of the find criteria
NoOfFinds = NoOfFinds + 1 'For testing with Msgbox only
Y.Font.ColorIndex = 5 'For testing purposes only
Set Y = rng2.FindNext(Y)
Loop While Not Y Is Nothing And Y.Address < InitAddress
End If
Next cell1
MsgBox "Total Number of finds = " & NoOfFinds 'For testing purposes only
End Sub


Hope this answers your question.


Regards,


OssieMac


"Dave Unger" wrote:


Hi OssieMac


Thanks for your reply. The problem here is the time difference. The
data I'm looking in was entered with date & time and is formatted as
"01/28/2007 04:59:59 PM". The find list contains date only,
"01/28/07", and changing the format results in "01/28/2007 12:00:00
AM". I want the time part disregarded, and have these 2 items 'match'
on the date part.


regards,


Dave.


On Feb 8, 7:59 pm, OssieMac
wrote:
Hi Dave. You need to format the find criteria the same as the column of
dates you are looking in so try this.


Dim DateToFind


For Each cell1 In rng1
DateToFind = Format(cell1,"mm/dd/yyyy")
Set Y = rng2.Find(what:=DateToFind, LookIn:=xlValues,
lookat:=xlPart)
Next cell1


"Dave Unger" wrote:
Hello,


I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".


The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.


For Each cell1 In rng1


Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)


Next cell1


Regards,


DaveU- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Date Find



"Dave Unger" wrote:

Hi OssieMac,

Thanks again. However, you must be using a newer version of Excel,
I'm using 97 and the FindFormat function isn't available. And I am
aware that the Find arguments should be set each time, just wanted to
keep the sample code as 'bare bones' as possible to illustrate my
approach. Appreciate your help.

regards,

Dave





On Feb 10, 5:15 am, OssieMac
wrote:
After thought. Include the following line at end of module.

Application.FindFormat.Clear

Also your code only included a minimum of arguments in the Find method. To
avoid problems, set all these arguments explicitly each time you use this
method because they are saved from previous finds and if you don't reset them
then the code may not work as you expect. Look up "Find Method" in the help
for VBA Editor and click on show all and read Remarks.



"OssieMac" wrote:
Sorry Dave. My mistake because I left a line out. However, to pay for my
mistake, I have tested the following and it not only finds the dates but
finds all occurrences if there is more than one match to the date. I actually
formatted them in the test macro and rng1 had no times associated with it
rng2 did have actual times.


Here is a small sample of the data I used:-
rng1 rng2
01/21/2006 01/13/2006 07:19:21
01/22/2006 01/14/2006 13:56:21
01/23/2006 01/15/2006 11:11:54
01/24/2006 01/16/2006 20:53:23
01/25/2006 01/17/2006 20:31:38
02/01/2006 01/18/2006 06:13:58
02/02/2006 01/19/2006 03:44:30
02/03/2006 01/20/2006 07:51:27
02/04/2006 01/21/2006 21:58:02
02/05/2006 01/22/2006 12:29:14
02/10/2006 01/23/2006 16:22:05


Dim DateToFind
Dim NoOfFinds
Dim InitAddress
Dim rng1 As Range
Dim rng2 As Range


Sub Find_Dates()
Sheets("Sheet1").Select
Set rng1 = Range("A2:A74") 'List of dates to find
rng1.Select
Selection.NumberFormat = "mm/dd/yyyy"
Set rng2 = Range("B2:B544")
rng2.Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm:ss" 'List of dates to search
Range("A1").Select
NoOfFinds = 0
For Each cell1 In rng1
DateToFind = Format(cell1, "mm/dd/yyyy")
Set Y = rng2.Find(What:=DateToFind, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False)
If Not Y Is Nothing Then 'Y is Not Nothing indicates found target
InitAddress = Y.Address 'Save the first address
Do 'Look for further occurrences of the find criteria
NoOfFinds = NoOfFinds + 1 'For testing with Msgbox only
Y.Font.ColorIndex = 5 'For testing purposes only
Set Y = rng2.FindNext(Y)
Loop While Not Y Is Nothing And Y.Address < InitAddress
End If
Next cell1
MsgBox "Total Number of finds = " & NoOfFinds 'For testing purposes only
End Sub


Hope this answers your question.


Regards,


OssieMac


"Dave Unger" wrote:


Hi OssieMac


Thanks for your reply. The problem here is the time difference. The
data I'm looking in was entered with date & time and is formatted as
"01/28/2007 04:59:59 PM". The find list contains date only,
"01/28/07", and changing the format results in "01/28/2007 12:00:00
AM". I want the time part disregarded, and have these 2 items 'match'
on the date part.


regards,


Dave.


On Feb 8, 7:59 pm, OssieMac
wrote:
Hi Dave. You need to format the find criteria the same as the column of
dates you are looking in so try this.


Dim DateToFind


For Each cell1 In rng1
DateToFind = Format(cell1,"mm/dd/yyyy")
Set Y = rng2.Find(what:=DateToFind, LookIn:=xlValues,
lookat:=xlPart)
Next cell1


"Dave Unger" wrote:
Hello,


I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".


The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.


For Each cell1 In rng1


Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)


Next cell1


Regards,


DaveU- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Date Find


I had a problem with my last posting and hence it is blank so I'll try again.

I've looked at the code again and you don't need the Find.Format. I've
modified the code below and taken it out and in fact it should not be there
for what you are trying to do and it was turned off in the Find command
anyway.

I believe that the code below it should work because although I am using Xl
2002 now, I originally found out about the need to reformat the search
criteria back when I was using Xl97 for a similar reason to yours although I
haven't actually got a copy of the code now. I still think that my original
comment about reformatting the Find criteria was right and then later my
advice to use all the arguments in the Find is essential. However, I invite
one of the professional experts to have a look and maybe they will refute
what I am saying.

Regards,

OssieMac

"OssieMac" wrote:



"Dave Unger" wrote:

Hi OssieMac,

Thanks again. However, you must be using a newer version of Excel,
I'm using 97 and the FindFormat function isn't available. And I am
aware that the Find arguments should be set each time, just wanted to
keep the sample code as 'bare bones' as possible to illustrate my
approach. Appreciate your help.

regards,

Dave





On Feb 10, 5:15 am, OssieMac
wrote:
After thought. Include the following line at end of module.

Application.FindFormat.Clear

Also your code only included a minimum of arguments in the Find method. To
avoid problems, set all these arguments explicitly each time you use this
method because they are saved from previous finds and if you don't reset them
then the code may not work as you expect. Look up "Find Method" in the help
for VBA Editor and click on show all and read Remarks.



"OssieMac" wrote:
Sorry Dave. My mistake because I left a line out. However, to pay for my
mistake, I have tested the following and it not only finds the dates but
finds all occurrences if there is more than one match to the date. I actually
formatted them in the test macro and rng1 had no times associated with it
rng2 did have actual times.

Here is a small sample of the data I used:-
rng1 rng2
01/21/2006 01/13/2006 07:19:21
01/22/2006 01/14/2006 13:56:21
01/23/2006 01/15/2006 11:11:54
01/24/2006 01/16/2006 20:53:23
01/25/2006 01/17/2006 20:31:38
02/01/2006 01/18/2006 06:13:58
02/02/2006 01/19/2006 03:44:30
02/03/2006 01/20/2006 07:51:27
02/04/2006 01/21/2006 21:58:02
02/05/2006 01/22/2006 12:29:14
02/10/2006 01/23/2006 16:22:05

Dim DateToFind
Dim NoOfFinds
Dim InitAddress
Dim rng1 As Range
Dim rng2 As Range

Sub Find_Dates()
Sheets("Sheet1").Select
Set rng1 = Range("A2:A74") 'List of dates to find
rng1.Select
Selection.NumberFormat = "mm/dd/yyyy"
Set rng2 = Range("B2:B544")
rng2.Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm:ss" 'List of dates to search
Range("A1").Select
NoOfFinds = 0
For Each cell1 In rng1
DateToFind = Format(cell1, "mm/dd/yyyy")
Set Y = rng2.Find(What:=DateToFind, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False)
If Not Y Is Nothing Then 'Y is Not Nothing indicates found target
InitAddress = Y.Address 'Save the first address
Do 'Look for further occurrences of the find criteria
NoOfFinds = NoOfFinds + 1 'For testing with Msgbox only
Y.Font.ColorIndex = 5 'For testing purposes only
Set Y = rng2.FindNext(Y)
Loop While Not Y Is Nothing And Y.Address < InitAddress
End If
Next cell1
MsgBox "Total Number of finds = " & NoOfFinds 'For testing purposes only
End Sub

Hope this answers your question.

Regards,

OssieMac

"Dave Unger" wrote:

Hi OssieMac

Thanks for your reply. The problem here is the time difference. The
data I'm looking in was entered with date & time and is formatted as
"01/28/2007 04:59:59 PM". The find list contains date only,
"01/28/07", and changing the format results in "01/28/2007 12:00:00
AM". I want the time part disregarded, and have these 2 items 'match'
on the date part.

regards,

Dave.

On Feb 8, 7:59 pm, OssieMac
wrote:
Hi Dave. You need to format the find criteria the same as the column of
dates you are looking in so try this.

Dim DateToFind

For Each cell1 In rng1
DateToFind = Format(cell1,"mm/dd/yyyy")
Set Y = rng2.Find(what:=DateToFind, LookIn:=xlValues,
lookat:=xlPart)
Next cell1

"Dave Unger" wrote:
Hello,

I have 2 columns of dates (rng1 and rng2). For each entry in rng1 I
need to find a match, if any, in rng2. Rng1 is formatted as
"01/28/07", while rng2 is "01/28/2007 05:00:00 PM".

The only way I can get the Find method to work is by formatting rng2
as serial, doing the
find, then restoring the original format. The example here seems to
be the only variation of Find that works for me. There must be a way
to avoid having to change the format.

For Each cell1 In rng1

Set Y = rng2.Find(what:=CLng(cell1), LookIn:=xlValues,
lookat:=xlPart)

Next cell1

Regards,

DaveU- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -




Reply
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
Find Specific date in Biwwekly Based on date jlclyde Excel Discussion (Misc queries) 3 January 27th 09 09:15 PM
Julian date - find next highest date/number jchick0909 Excel Worksheet Functions 1 March 20th 08 11:38 PM
Find the date of the coming up Saturday given the current date. Michael Ermino Excel Worksheet Functions 4 April 11th 07 02:48 AM
Using variables to make a date and using find method to find that. KyWilde Excel Programming 2 April 21st 05 09:43 PM
Find date and copy range based on that date avzundert Excel Programming 2 November 25th 04 10:31 AM


All times are GMT +1. The time now is 11:07 PM.

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

About Us

"It's about Microsoft Excel"