View Full Version : Solved: Finding in Reverse Order
How can I modify the following code to find the row number for the last instance of the search term in a column containing multiple instances of the term?
Thanks,
Opv
Sub findIt()
Dim a As Integer
a = Range("A:A").Find("Test").Row
MsgBox (a)
End Sub
mdmackillop
03-24-2010, 12:27 PM
a = Range("A:A").Find("Test", after:=Cells(1, 1), searchdirection:=xlPrevious).Row
mdmackillop
03-24-2010, 12:31 PM
BTW,
Use Long, not integer
(http://javascript<b></b>:hhobj_4.Click())
Integer variables (http://javascript<b></b>:hhobj_4.Click()) are stored as 16-bit (2-byte) numbers ranging in value from -32,768 to 32,767.
(http://javascript<b></b>:hhobj_4.Click())
You'll get an error if the row number exceeds 32,767
a = Range("A:A").Find("Test", after:=Cells(1, 1), searchdirection:=xlPrevious).Row
Thanks. I am amazed at all that can be done with VBA.
Opv
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.