ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Find Last Occurence in a Range with VBA (https://www.excelbanter.com/excel-discussion-misc-queries/204557-find-last-occurence-range-vba.html)

jlclyde

Find Last Occurence in a Range with VBA
 
I am using find to get the first address of occurences in a row, but
how do you get the last occurence?

Thanks,
Jay

Bernie Deitrick

Find Last Occurence in a Range with VBA
 
Jay,

Dim myC As Range
Set myC = Range("A2:A100").Find("Jay", , , , , xlPrevious)
MsgBox myC.Address

HTH,
Bernie
MS Excel MVP



"jlclyde" wrote in message
...
I am using find to get the first address of occurences in a row, but
how do you get the last occurence?

Thanks,
Jay




jlclyde

Find Last Occurence in a Range with VBA
 
On Sep 30, 5:17*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Jay,

Dim myC As Range
Set myC = Range("A2:A100").Find("Jay", , , , , xlPrevious)
MsgBox myC.Address

HTH,
Bernie
MS Excel MVP

"jlclyde" wrote in message

...



I am using find to get the first address of occurences in a row, but
how do you get the last occurence?


Thanks,
Jay- Hide quoted text -


- Show quoted text -


This was not what I was thinking but this will do nicely.
Thanks,
Jay


All times are GMT +1. The time now is 12:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com