Sheet1!A - Date format
Sheet1!B - Time format
Sheet1!F - Number format
Sheet1!K - Number format
Sheet2!D6 - Date format
Sheet2!D7 - Time format
Sheet2!D8 - Number format
Here is algorithm:
1. Find all lines in Sheet1!A that contains Steet2!D6.
If nothing found Then Sheet2!D8="nothing found", exit macros.
2. In lines from step 1, find line in Sheet1!B that contains Sheet2!D7.
If nothing found Then Sheet2!D8="nothing found", exit macros.
3. If(Sheet1!F(#line from step 2) < Sheet!K(#line from step 2), Sheet2!D8=1, Sheet2!D8=0)<sheet!k(#line from="" step="" 2),="" sheet2!d8="1,"><sheet!k(#line from="" step="" 2),="" sheet2!d8="1,">
Thanks,
Dana
</sheet!k(#line></sheet!k(#line>
Sheet1!B - Time format
Sheet1!F - Number format
Sheet1!K - Number format
Sheet2!D6 - Date format
Sheet2!D7 - Time format
Sheet2!D8 - Number format
Here is algorithm:
1. Find all lines in Sheet1!A that contains Steet2!D6.
If nothing found Then Sheet2!D8="nothing found", exit macros.
2. In lines from step 1, find line in Sheet1!B that contains Sheet2!D7.
If nothing found Then Sheet2!D8="nothing found", exit macros.
3. If(Sheet1!F(#line from step 2) < Sheet!K(#line from step 2), Sheet2!D8=1, Sheet2!D8=0)<sheet!k(#line from="" step="" 2),="" sheet2!d8="1,"><sheet!k(#line from="" step="" 2),="" sheet2!d8="1,">
Any ideas how can I optimize the code?Sub macro()
Dim l As Integer
Range("d8") = "": l = 0
Do
l = l + 1
If Sheets(1).Cells(l, "a") = Sheets(2).Range("d6") Then
If Sheets(1).Cells(l, "b") = Sheets(2).Range("d7") Then
If Sheets(1).Cells(l, "f") < Sheets(1).Cells(l, "k") Then Range("d8") = 1 Else Range("d8") = 0
End If
End If
Loop Until (l = Sheets(1).Cells.SpecialCells(xlLastCell).Row + 1 Or Range("d8") <> "")
If Range("d8") = "" Then Range("d8") = "nothing found"
End Sub
Thanks,
Dana
</sheet!k(#line></sheet!k(#line>
Last edited: