Find last occurrence of the value Yes
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. |
Find last occurrence of the value Yes
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 --------------- Jacob Skaria "ordnance1" wrote: 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. |
Find last occurrence of the value Yes
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 -- Rick (MVP - Excel) "ordnance1" wrote in message ... 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. |
All times are GMT +1. The time now is 03:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com