Are you saying that after running the code I gave you, hitting Ctrl+End
still takes you to Row 350? If so, then something else may be going on... if
you want, you can send the workbook to me and I'll look at what you actually
have (remove the NO.SPAM stuff from my posted email address).
Just so you know, my code adds an "X" to the row after the last piece of
data (or formula) so that Excel has something to delete... just deleting
what Excel thinks are already blank rows does not readjust the UsedRange...
it seems Excel must actually have something to delete before it will adjust
the UsedRange. This line...
..Range(.Rows(LastRow + 1), .Rows(.UsedRange.Rows.Count)).Delete
deletes the row I put the "X" in down to the last row Excel "thinks" is in
use... it doesn't just delete the cell I added the "X" to.
--
Rick (MVP - Excel)
"RLN" <rlntemp-(E-Mail Removed)> wrote in message
news:3913e629-31d6-4510-a793-(E-Mail Removed)...
Rick,
I tried this code here you provided and it is not doing what I thought
it would do.
My sheet has 35 rows of valid data (this row qty can vary from month
to month)
In this particular case, a <ctrl+home>, <ctrl+end> revealed this sheet
has not 35 rows, but 350 rows. Rows 36-350 are completely blank and
contain nothing. Rows 36-350 are the rows I'm trying to delete (then
do a save afterwards).
As I stepped through your code with the debugger, all I saw it really
do was place an "X" in column 1 of row 36, then delete row 36.
Is there is something else I might be missing here?
On May 6, 12:29 pm, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> The problem is with the UsedRange that Excel tracks... under certain
> conditions, it doesn't get updated to reflect the actually used range of
> data. I think this macro will fix the problem you are having (provided
> your
> data never goes down to the very last row on the worksheet)...
>
> Sub FixUsedRange()
> Dim LastRow As Long
> With ActiveSheet
> LastRow = .Cells.Find(What:="*", SearchOrder:=xlRows, _
> SearchDirection:=xlPrevious).Row
> .Cells(LastRow + 1, 1).Value = "X"
> .Range(.Rows(LastRow + 1), .Rows(.UsedRange.Rows.Count)).Delete
> End With
> End Sub
>
> --
> Rick (MVP - Excel)
|