View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chris Chris is offline
external usenet poster
 
Posts: 244
Default Here's a simple routine for LastRow, LastColumn

I put together a simple routine that will find the last Row and last Column w/ data in a spreadsheet
Without the pitfalls and limitations of
End(xlup), End(xlDown) and "simple" UsedRange
Any critique is welcomed

Sub LstRow_LstColumn(
Dim Rw As Range, Clm As Rang
Dim x As Single, LRw As Single, LClm As Singl

If WorksheetFunction.CountA(ActiveSheet.UsedRange) = 0 Then Exit Su
With ActiveSheet.UsedRange
D
x = x +
Set Rw = .Offset(.Rows.Count - x).Resize(1
Loop Until WorksheetFunction.CountA(Rw) <
LRw = Rw.Ro
x =
D
x = x +
Set Clm = .Offset(0, .Columns.Count - x).Resize(, 1
Loop Until WorksheetFunction.CountA(Clm) <
LClm = Clm.Colum
End Wit
End Sub