Consulting

Results 1 to 3 of 3

Thread: Using Union Method

  1. #1
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location

    Using Union Method

    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?
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  2. #2
    VBAX Regular vonpookie's Avatar
    Joined
    Jun 2004
    Location
    Are we there yet?
    Posts
    74
    Location
    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?

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by vonpookie
    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.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •