Referencing Merged Cells in VBA
On Sun, 09 May 2010 08:54:26 -0400, GS wrote:
Hi Ron,
Just want to confirm what you already state you just discovered: -the
ref address of a merged area is always the first (top left) cell in the
group. You're going to have some unexpected results when working with
merged cells, depending on what your code is doing with them. What's
important about working with DATA in merged cells is the ref address.
Thank you for confirming that. I made my "discovery" empirically and it's good
to have confirmation.
Also, depending on why the cells are merged, there may be other ways to
show data with using Alignment settings. This avoids having to work
with merged cells in a single row. (i.e.: Center across selection,
Distributed)
The Excel sheets are coming from a gov't source over which I have zero
control/input/influence/etc. So although there may be other, equally effective
methods of displaying the data, I don't really have any choice other than to
deal with the data as presented. I suppose I could write a routine to reformat
the information, but I doubt that would be any easier than to just handle it
directly.
For example, in the data, E14:E16 is a merged cell, as is H14:H16.
The separate lines of data in F14, F15 and F16 each refer to the data in the
merged cells on either side.
--ron
|