View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB
 
Posts: n/a
Default FindFirst, FindLast and select

If you have the Firstcell and LastCell, then all you should need is
Range(FirstCell,LastCell).Select



Sub SelectRange()
Dim MyRange As Range
Dim FirstCell As Range
Dim LastCell As Range
Const Criteria = "YourCriteria"

Set MyRange = Selection 'Or whatever else you want

Set LastCell = MyRange.Find(what:=Criteria, _
after:=MyRange.Cells(1, 1), searchdirection:=xlPrevious)
Set FirstCell = MyRange.FindNext(LastCell)

If Not FirstCell Is Nothing And _
Not LastCell Is Nothing Then _
Range(FirstCell, LastCell).Select

End Sub


"Noemi" wrote:

Hi

I am after the VBA code which will allow me to find the first text eg "Test"
and then find the last text eg "Test" and highlight from the first "Test" to
the last "Test" found.

I understand about using the find and findlast but I dont know how I combine
the 2 so I can select both cells plus all the cells inbetwwen them.

I hope someone can help.

Thanks
Noemi