View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default I Need VBA Assistance looking for End of a file

Here is some fairly straightforward code. You can use rngCurrentSpot the same
as you would use Activecell.

Private Sub Traverse()
Dim lngLastRow As Long
Dim rngCurrentSpot As Range

lngLastRow = ActiveSheet.Range("A65535").End(xlUp).Row
Set rngCurrentSpot = ActiveSheet.Range("A2")
Do While rngCurrentSpot.Row <= lngLastRow
MsgBox rngCurrentSpot
Set rngCurrentSpot = rngCurrentSpot.Offset(1, 0)
Loop
End Sub

There are lots of other ways to do this that you might want to investigate
including:
SpecialCells(xlLastCell)
UsedRange

HTH

"Brent E" wrote:

Good afternoon,

I need to know a VBA command that will look at all cells in Column B until
end of file or EOF. I tried DO UNTIL ... EOF, but didn't seem to work. Any
suggestions? Thanks.