VBA-addict
New Member
- Joined
- Apr 1, 2011
- Messages
- 3
This issue is widely discussed in the Internet, but for simplistic cases - when we have a rectangular Selection or when it goes about last filled in cell on a Worksheet.
My question is different: Suppose we selected with Ctrl single cells: C5;A1;B3 - I need to get C5 as first cell then and B3 as last one.
Actually Selection.Address gives the following:
$C$5,$A$1,$B$3 - which is correct, but
Selection.Cells(Selection.Cells.Count).Address
gives you not B3 as it may be expected but $C$7
Selection.SpecialCells(xlCellTypeLastCell).Address
gives you Right Bottom cell
$C$5
The only solution I found so far, to parse Selection.Address with InStr and InStrRev Functions to find "$" as pivots to extract addresses ("," would not be used for that as I'm not sure for other Excels if it's "," or ";" and then for rectangular selection it will be ":")
My question is different: Suppose we selected with Ctrl single cells: C5;A1;B3 - I need to get C5 as first cell then and B3 as last one.
Actually Selection.Address gives the following:
$C$5,$A$1,$B$3 - which is correct, but
Selection.Cells(Selection.Cells.Count).Address
gives you not B3 as it may be expected but $C$7
Selection.SpecialCells(xlCellTypeLastCell).Address
gives you Right Bottom cell
$C$5
The only solution I found so far, to parse Selection.Address with InStr and InStrRev Functions to find "$" as pivots to extract addresses ("," would not be used for that as I'm not sure for other Excels if it's "," or ";" and then for rectangular selection it will be ":")