View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Selection range to last non empty cell

Maybe...

Option Explicit
Sub testme2()

Dim FirstCell As Range
Dim SecondCell As Range
Dim RngToSearch As Range

With ActiveSheet
Set FirstCell = .Range("a3")
Set RngToSearch = .Range("a3", .Cells(.Rows.Count, "A").End(xlUp))

With RngToSearch
Set SecondCell = .Cells.Find(what:="Team", _
after:=.Cells(1), lookat:=xlWhole, _
searchorder:=xlByRows, searchdirection:=xlNext, _
MatchCase:=False)

If SecondCell Is Nothing Then
'not found
Set SecondCell = FirstCell
End If
End With

.Range(FirstCell, SecondCell).Select
End With

End Sub




Jaan wrote:

Does anyone know how I could write a macro to select range from A3 to value
"TEAM"?


--

Dave Peterson