Find last occurrence of the value Yes

O

ordnance1

I have column R, which contains a series of Yes, and No values. There are
also blank cells within the column.

I need some code that will find the last occurrence of Yes in the column and
select it.
 
J

Jacob Skaria

Try the below code which works on 'Sheet1' Col R. Adjust to suit

Sub Macro()
Dim varFound As Variant, varRange As Variant
With Worksheets("Sheet1").Range("R:R")
Set varFound = .Find("Yes", LookIn:=xlValues)
If Not varFound Is Nothing Then
Do
Set varRange = varFound
Set varFound = .FindNext(varFound)
Loop While Not varFound Is Nothing And _
varFound.Row > varRange.Row
varRange.Select
End If
End With
End Sub

If this post helps click Yes
 
R

Rick Rothstein

I believe this macro will do what you want...

Sub FindLastYes()
On Error Resume Next
Columns("R").Find("Yes", MatchCase:=False, _
SearchDirection:=xlPrevious).Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top