J
joeu2004
In a VBA subroutine, I want to write something like:
Dim r as Range, s as String, n as Long
[...set up r, s and eventually n...]
r.Value = s
r.Resize(1, n).mergeCells = True
The problem is: how can I determine n, the number of colums merge?
My current workaround is to set n to a constant, namely the maximum
number of columns to merge, which I determined by inspection
beforehand. There is nothing to the right of r. I am not happy with
the "by inspection" requirement; I am actually iterating through all
rows in a large worksheet. Moreover, I want n to be the __minimum__
number of columns necessary.
Dim r as Range, s as String, n as Long
[...set up r, s and eventually n...]
r.Value = s
r.Resize(1, n).mergeCells = True
The problem is: how can I determine n, the number of colums merge?
My current workaround is to set n to a constant, namely the maximum
number of columns to merge, which I determined by inspection
beforehand. There is nothing to the right of r. I am not happy with
the "by inspection" requirement; I am actually iterating through all
rows in a large worksheet. Moreover, I want n to be the __minimum__
number of columns necessary.