Private Sub CommandButton5_Click()
Dim a, b, c, d, e, f, g, aa, U, V
For k = 3 To 12
If Cells(k, "M") > [v6] Then
' If Cells(k, "M") > TimeValue(Now) Then
Set a = Cells(k, "M")
Exit For
End If
Next
Set b = a.Offset(-1)
For c = 41 To 1200
If Cells(c, "a") > b Then
Set e = Cells(c, 1)
Exit For
End If
Next
Set g = Range("a65536").End(xlUp).Offset(0)
For d = g.Row To 21 Step -1
If Cells(d, "a") < a Then
Set f = Cells(d, 1)
Exit For
End If
Next
U = e.Offset(0, 2).Address
V = f.Offset(0, 2).Address
Set aa = Range(U, V).Find(Application.Large(Range(U, V), 1), LookIn:=xlValues, LookAt:=xlWhole)
End Sub |