View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_11_] Bob Phillips[_11_] is offline
external usenet poster
 
Posts: 1
Default how to reset the activesheet usedrange value


Unfortunately it is more complicated than that

Sub ResetUsedRange()
Dim iLastRow As Long
Dim iLastCol As Long
Dim rng As Range


With ActiveSheet
iLastRow = 0
iLastCol = 0
Set rng = .UsedRange
On Error Resume Next
iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
iLastCol = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
On Error GoTo 0

.Range(.Cells(iLastRow + 1, 1), _
.Cells(.Rows.Count, 1)).EntireRow.Delete
.Range(.Cells(1, iLastCol + 1), _
.Cells(1, .Columns.Count)).EntireColumn.Delete
End With

End Su

--
Bob Phillip
-----------------------------------------------------------------------
Bob Phillips's Profile: http://www.excelforum.com/member.php...fo&userid=2695
View this thread: http://www.excelforum.com/showthread.php?threadid=47129