+ Reply to Thread
Results 1 to 8 of 8

Explain Union and delRange to me.

  1. #1
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Explain Union and delRange to me.

    Is there any difference using
    Please Login or Register  to view this content.
    as opposed to
    Please Login or Register  to view this content.
    Also, I read that in Excel 2003, if the parameter/cell contains nothing within the Union, then that parameter is not selected. Is this still true in Excel 2010 onwards?

    --------------------------

    What exactly is
    Please Login or Register  to view this content.
    I couldn't really find any documentation on it explaining it in detail. All I could glean is that it is used to set a range to delete.

    For example:
    Please Login or Register  to view this content.
    This code actually deletes it :
    Please Login or Register  to view this content.
    I'm assuming that if delRange has not nothing (aka has columns saved), then delete the range.

    From what I understand, if the value is "Help" and delRange is not set, then set it to Column i. I don't really follow the part after the "Else". Does it mean that if there is already a delRange, then combine the previous delRange and the new Column i (which is repeated later on using next i code) together to be deleted later?

    Also: bonus points if you can tell me what "Call" does. To me, it just seems similar to ".Select" but is it just used for functions?
    Last edited by jhuang5132; 09-08-2014 at 11:24 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Explain Union and delRange to me.

    Quote Originally Posted by jhuang5132 View Post
    Is there any difference using
    Please Login or Register  to view this content.
    as opposed to
    Please Login or Register  to view this content.
    No - unless you have another routine called Union.

    Also, I read that in Excel 2003, if the parameter/cell contains nothing within the Union, then that parameter is not selected. Is this still true in Excel 2010 onwards?
    No idea what you mean, I'm afraid.

    What exactly is
    Please Login or Register  to view this content.
    I couldn't really find any documentation on it explaining it in detail. All I could glean is that it is used to set a range to delete.
    It's just a variable name.

    I don't really follow the part after the "Else". Does it mean that if there is already a delRange, then combine the previous delRange and the new Column i (which is repeated later on using next i code) together to be deleted later?
    That's correct.

    Also: bonus points if you can tell me what "Call" does. To me, it just seems similar to ".Select" but is it just used for functions?
    It is used to call other routines. (it isn't required). It is nothing like .Select though.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Explain Union and delRange to me.

    Thanks Rory, that was very informative. I didn't really realize that delRange was just a very common variable like LastRow. Would that also mean that
    Set delRange = .Columns(i)
    can just be stated as
    delRange = .Columns(i)
    or is "Set" necessary because it is in an If Function?


    For the part you didn't understand, I was just bad at explaining.

    ----

    Here's a direct quote:

    The Union method, though, has two shortcomings. First, none of its input parameters may be Nothing. If any parameter is Nothing, the Union operation fails. A better union, described below, will ignore parameters that are Nothing and uses only the parameters that not Nothing to create the new range. The second shortcoming of Union is that it duplicates cells when the regions specified by the input parameters overlap. This can cause logic problems in your code since overlapping cells are included twice in the Union result.
    http://www.cpearson.com/excel/BetterUnion.aspx

    Would this still be applicable to 2010?
    Last edited by jhuang5132; 09-08-2014 at 11:46 AM.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Explain Union and delRange to me.

    Set is necessary because delRange is an object variable, not a data type.

    The Union method has not changed in 2010 - it still has the same limitations.

  5. #5
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Explain Union and delRange to me.

    Sorry, I don't quite follow that.

    Is it an object variable because if refers to a range, rather than a value, which would be a data type?

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Explain Union and delRange to me.

    That's correct.

  7. #7
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Explain Union and delRange to me.

    Thanks again! Useful information.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Explain Union and delRange to me.

    Glad to help. Please don't forget to mark the thread solved using the Thread Tools link at the top of the page.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] union cells
    By max_max in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-16-2013, 02:28 PM
  2. VBA - Help with Union All
    By JohnM3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2011, 05:14 PM
  3. Compiling a Union
    By Warbe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-22-2011, 12:00 PM
  4. [SOLVED] Union
    By Arne Hegefors in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2006, 11:30 AM
  5. [SOLVED] UNION of Arrays - is possible?
    By Marina Limeira in forum Excel General
    Replies: 1
    Last Post: 01-22-2006, 08:40 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1