Normally the 'LastCell' is the intersection of the lower-most row and
right-most column that each contain data and/or some formatting. Row height
counts as a format for this purpose, however entire rows/columns of
identical formatting do not (except where they intersect). The last-cell
itself might be totally empty of both data and formats. The LastCell can be
selected by pressing Ctrl-End or referenced by .SpecialCells(xlLastCell).
Say currently the Last Cell is "J10", If columns "H:J" and rows 8:10 are
deleted (ie all data & all formats removed), one might reasonably expect the
LastCell to become "G7". But it doesn't, it remains as "J10".
Usually the LastCell can be 'corrected' to G7 with any use of .UsedRange, as
in the example I gave, which appears to work fine for the OP.
As Mark says UsedRange is Read-only, however it does serve to reset the used
range. Very occasionally it doesn't reset some worksheets where saving the
wb would.
Regards,
Peter T
Mike H. said:
Okay, so I enter something in the cell I wish to make the last cell and then
execute the sub and nothing happens. Am I missing something or how do you
"Make it so"?
Mark Lincoln said:
UsedRange is read-only. You need to enter something in the cell you
want to be the "end" to make it so.
Mark Lincoln
I wrote this sub:
Sub ResetUsedRange()
ActiveSheet.UsedRange
End Sub
Then i place my cursor in the cell I want to be the end and execute the
macro and nothing changes. Ideas?
:
How can I change where ctrl-End goes to?
[....]
ActiveSheet.UsedRange ' typically works but not in all scenarios
Works great for me. Just want I needed. Thanks much.- Hide quoted text -
- Show quoted text -