View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
CoolBusiness CoolBusiness is offline
external usenet poster
 
Posts: 8
Default End(xlUp) question

I wrote this code which seems to work beautifully. My table's first
available row is 11 and ends at 5000. I couldn't make the End(xlUP) work in
the table if any cell within the row had a formula. This seems to be the
answer. If there's a better or less intensive way, please let me know.
Thanks.

Sub Determine_Last_Row()
'
' Determine_Last_Row Macro
'

Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row

For X = LastRow To 11 Step -1
If Cells(X, 1).Value < "" Then
Cells(X, 1).Offset(1).Select
GoTo EndRoutine
End If
Next X
EndRoutine:

End Sub



"CoolBusiness" wrote:

I have a table which ends at row 5000. Using the following line in a macro
ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Select
goes to row 5000 each time even thought the last row with data is much
further up. Is Excel interpreting the last row of a table as containing
data? This should be simple but I'm stumped as to why it is doing this.