+ Reply to Thread
Results 1 to 6 of 6

How to combine separate columns in to single range

  1. #1
    Registered User
    Join Date
    05-20-2011
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    5

    How to combine separate columns in to single range

    Hello,

    I have a range a1:a5 and d1:d5. I need to define both columns under a single named range(myRange). Currently, if I do so and then try to use it, for example: =columns(myRange) I'd expect to have "2" returned, but instead I get an error. Please help how can I define such range to use it as a single array.
    Thanks!!

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: How to combine separate columns in to single range

    Hi,

    Your array is defined as you require.

    =COLUMNS() will return an error for a non-continuous range (ie, two or more separate columns)
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    05-20-2011
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: How to combine separate columns in to single range

    Quote Originally Posted by sweep View Post
    Hi,

    Your array is defined as you require.

    =COLUMNS() will return an error for a non-continuous range (ie, two or more separate columns)
    Thanks for your reply! Is there a way to define it as a continious range? I'm trying to use it as a data source for a listbox, but the listbox doesn't like it either having a non-continious range.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: How to combine separate columns in to single range

    Hi is49460 and welcome to the forum,

    I guess the answer to your question is "That's the way it works!".

    Your named range of myRange isn't a single array but multiple arrays. You can do functions like: Sum(myRange) and get good answers but Columns() needs a single array instead of multiple arrays. Throwing in a named range works only if the named range is a single array.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    05-20-2011
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: How to combine separate columns in to single range

    Quote Originally Posted by MarvinP View Post
    Hi is49460 and welcome to the forum,

    I guess the answer to your question is "That's the way it works!".

    Your named range of myRange isn't a single array but multiple arrays. You can do functions like: Sum(myRange) and get good answers but Columns() needs a single array instead of multiple arrays. Throwing in a named range works only if the named range is a single array.
    That makes sense. Although, I was hoping there is a function of some sort that would take multiple ranges and return a single one... but i guess I'm out of luck. Thanks again!

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: How to combine separate columns in to single range

    I think you were on the right track using named ranges. It just works out that named ranges can't be used in all formulas, depending on what the named range defines.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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