Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default last occurence

can it be possible to find the last occurence of a word,
rather than the 1st occurence in a particular column. I
hope i am clear

thanks
monika
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default last occurence

Public Function LastOcc(Table As Range, Value As Variant)
' Finds the last occurence of a value in the first column

Dim i As Integer

For i = 1 To Table.Rows.Count

If Table.Cells(i, 1) = Value Then
LastOcc = i
End If

Next i

End Functio

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default last occurence

Hi Monika.

This is modification of a function that finds you the k-th occurence of
a value. I didn't try it out so let me know in case it doesn't work,
alright?

Fabalicious


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default last occurence

How about this:

Sub test()
Dim rng As Range

With ActiveSheet.Columns(2)
Set rng = .Find("FindMe", .Cells(1), xlValues, xlPart, xlByColumns,
xlPrevious, False)
If Not rng Is Nothing Then rng.Select
End With
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"monika" wrote in message
...
can it be possible to find the last occurence of a word,
rather than the 1st occurence in a particular column. I
hope i am clear

thanks
monika



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default last occurence

Public Function LastOcc(Table As Range, Value As Variant, Col A
Integer)
' Finds the last occurence of a value in the first column

Dim i As Integer

For i = 1 To Table.Rows.Count

If Table.Cells(i, Col) = Value Then
LastOcc = i
End If

Next i

End Function


...almost the same as above but the function takes the column you wan
to search in as an argument (while before search could only b
performed in column 1). there's one restriction to this solution: th
cell containing the function should not be in the same column you ar
looking for occurences ... (will return '0' otherwise even if you
value does occur in this column)

Fa

--
Message posted from http://www.ExcelForum.com

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
Get the second Occurence of something Totti New Users to Excel 3 November 17th 08 08:18 PM
next occurence Zab Excel Worksheet Functions 0 February 26th 08 06:49 PM
Occurence #'s Seveneleven Excel Discussion (Misc queries) 6 February 7th 06 07:38 PM
get 2nd occurence value TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 October 1st 05 08:00 AM
Frequency of occurence Danny J Excel Worksheet Functions 1 March 9th 05 12:14 AM


All times are GMT +1. The time now is 05:23 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"