Getting Selected

J

John

If macro starts with a selected area (by mouse) how do you get the
corner cells of the selected area? In other words obtain the cell:cell form.

Thanks
 
I

Iain King

John said:
If macro starts with a selected area (by mouse) how do you get the
corner cells of the selected area? In other words obtain the cell:cell form.

Thanks

you need to use the AddressLocal property of the selected Range. So:

strTopLeft = Activesheet.Cells(Selection.Row, Selection.Column).AddressLocal
strBottomRight = Activesheet.Cells(Selection.Row+Selection.Rows.Count-1,
Selection.Column+Selection.Columns.Count-1).AddressLocal

Iain King
 
D

Dave Peterson

dim myRng as range
set myRng = selection.areas(1)

msgbox myrng.cells(1).address
msgbox myrng.cells(myrng.cells.count).address


I used Areas(1) just in case you have more than one area selected.
 
I

Iain King

oops, not quite finished :)
strTopLeft = Activesheet.Cells(Selection.Row, Selection.Column).AddressLocal
strBottomRight = Activesheet.Cells(Selection.Row+Selection.Rows.Count-1, _
Selection.Column+Selection.Columns.Count-1).AddressLocal

strSelectedRange = strTopLeft+":"+strBottomRight

Iain King
 
Top