PDA

View Full Version : [SOLVED] Using Union Method



MWE
09-29-2005, 11:07 AM
I am using the Union method to "grow" a range. Each growth increment is via

Set Target = Union(Target,NewRange)

NewRange is typically a single cell. After a few iterations, I test the size of Target and get very strange results. The value for Target.Row and Target.Column is as I would expect. But the value for Target.Rows and Target.Columns is not the number of rows or cols in the current range; but, rather, is the "value" for the last cell (range) added.

Does this make any sense?

vonpookie
09-29-2005, 11:18 AM
I think Target.Rows.Count may work better than just Target.Rows (that's what I would use at any rate, but that doesn't necessarily mean I'm right).

But is this in a "normal" macro or an Event macro such as Worksheet_Change? Because those already have the Target value dimmed as a range--and it will be whatever cell was changed and triggered the code, which could possibly account for weirdness?

MWE
09-29-2005, 12:04 PM
I think Target.Rows.Count may work better than just Target.Rows (that's what I would use at any rate, but that doesn't necessarily mean I'm right).

But is this in a "normal" macro or an Event macro such as Worksheet_Change? Because those already have the Target value dimmed as a range--and it will be whatever cell was changed and triggered the code, which could possibly account for weirdness?
the problem is brain death at my end. I was using the wrong properties. Temp.Rows.Count is right.