• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Using VBA to Select "Corner Cell" in Excel.. Cell in last row and last column...

ArbeitWali

New Member
Trying to have VBA Select "Corner Cell" in Excel..
Cell in last row and last column...


So I'm starting from a point where the region is already selected.... the region having just been pasted.
 
You can use something like below:
Code:
Sub BottomRightCell()
Dim rngBtmRgt As Range
Set rngBtmRgt = Selection.Cells(Selection.Rows.Count, Selection.Columns.Count)
MsgBox rngBtmRgt.Address
End Sub
 
Thanks everyone for these great codes
What about this
Code:
Sub Test()
    MsgBox Selection.SpecialCells(xlCellTypeLastCell).Address
End Sub
 
That's weird ...
I have tested it on colored selection and it worked .. the range is empty but it has interior color ...So it will not deal with the range (selection) if it is clear at all
Untitled.png
 
That's weird ...
I have tested it on colored selection and it worked .. the range is empty but it has interior color ...So it will not deal with the range (selection) if it is clear at all
View attachment 29195
What result do you get if you type something in I21?

xlCellTypeLastCell returns the last cell in the sheet which is bottom-right corner of usedrange so it will invariably give wrong results than right.
 
Back
Top