Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Last Occurrence of Number KimC Excel Discussion (Misc queries) 4 January 12th 09 03:24 AM
How to find SECOND occurrence in a string? Bill_S Excel Worksheet Functions 4 March 19th 07 06:49 PM
find first occurrence of data in a column mpierre Excel Programming 2 December 10th 06 02:27 PM
Find nth occurrence and replace with ":" marlea Excel Worksheet Functions 4 October 5th 05 10:43 PM
find last occurrence REMnLYN Excel Worksheet Functions 9 March 29th 05 10:43 AM


All times are GMT +1. The time now is 05:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"