I don't think the range is named before you merge it that or either only the top left most cell of the range is named before merge - in either case you would get 1 as you outline.
Merged cells do not work quite as people think - in reality the content of the merged area generally resides only in the top left most cell of the merged area.
will return value of zaza
will return nothing (blank/0) assuming it (A2) was empty prior to being merged.. although part of the merged area it is itself devoid of content - the content exists only in A1
So ... my point was basically... if you had A1:D5 highlighted, then named, then merged - ROWS and COLUMNS would return the expected values.
I'm not sure, off hand, is there is a native function you can use to determine the address of a merged area if the area is named after the merge or only the top left cell is named before merge ... I think you would be looking at VBA
(things are also complicated of course by the fact that any given name can cover multiple non-contiguous areas - merged or not)
stored in a Module in VBE, called from a cell along the lines of:
where the first parameter is the range of interest and the second (0,1) stipulates whether you're returning Rows (0) or Columns (1) ... for a non-contiguous range like A6:C7, B12:C13 the above would return 4 for rows and 3 for columns.
I'm sure there are far more elegant and robust methods out there to do this kind of analysis though.
EDIT: code corrected - missing a release of rngRC in the Loop
Bookmarks