Thread: Searching dates
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Searching dates

Option Explicit
Sub AA()
Dim icol As Long, i As Long, j As Long
Dim k As Long, v As Variant, v1 As Variant
Dim tbl As Range, tbl1 As Range
Dim res As Variant, cnt As Long
Set tbl = Range(Cells(1, 3), _
Cells(1, 3).End(xlDown)).Resize(, 21)
Set tbl1 = Range(Cells(1, "y"), _
Cells(1, "y").End(xlDown)).Resize(, 5)
For i = 1 To tbl1(tbl1.Count).Row
icol = 31
v = Cells(i, 25).Resize(1, 5).Value
For j = 1 To tbl(tbl.Count).Row
v1 = Cells(j, 3).Resize(1, 21)
cnt = 0
For k = 1 To 5
res = Application.Match( _
v(1, k), v1, 0)
If Not IsError(res) Then
cnt = cnt + 1
End If
If cnt < k Then Exit For
Next k
If cnt = 5 Then
Cells(i, icol) = Cells(j, 2).Value
icol = icol + 1
End If
Next j
Next i
End Sub

--
Regards,
Tom Ogilvy





"mac_see" wrote in message
...
To explain my question in a better way I have uploaded my worksheet on my
website http://www25.brinkster.com/shreejipc/Mihit/Book2.htm

What I want to do is:

Search all the five numbers 7 40 61 62 68 in the first row (1-Sep). If all
the 5 numbers are present in that row, put the date 1-Sep in cell AE1. If
not, go to the second row. Do this till the last row.

Do the same task for the next range 10 11 42 45 63

The answer is AE1 will have 2-Sep as all the five number were present in

the
second row and AF1 will have 5-Sep again the same 5 numbers were present

in
5th row.

AE2 will have 3-Sep as 10 11 42 45 63 were present in the 3rd row.

I have data will march end and doing this manully will be a very tedious
task. Can this be automated using a formula or VBA?

Maxi