Try this VBA solution
Sub FindFirstInstance()
Dim WHAT2 As Date
WHAT2 = Date
Dim ws As Excel.Worksheet
Dim FoundCell As Excel.Range
Dim i As Long
Set ws = ActiveSheet
Set FoundCell = ws.Range("B:B").Find(WHAT:=WHAT2, lookat:=xlWhole)
'If Not FoundCell Is Nothing Then
'MsgBox (WHAT2 & " found in row: " & FoundCell.Row)
'Else
'MsgBox (WHAT2 & " not found")
'End If
For i = FoundCell.Row To 1 Step -1
If Range("D" & i) = 0 Then
MsgBox (Range("B" & i + 1))
Exit Sub
Else
End If
Next i
End Sub
How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
Bookmarks