+ Reply to Thread
Results 1 to 14 of 14

Creating an array from multiple, sepearated cells

  1. #1
    Registered User
    Join Date
    09-22-2013
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    17

    Creating an array from multiple, sepearated cells

    I'm trying to use conditional formatting to highlight cells. I want the lowest (Done) and second lowest (problem) to be highlighted.

    From what I can find, SMALL is the best option for what I need, however, I don't have a solid array, but instead the values I need to compare are on H2, L2, and P2. The structure of the sheet doesn't allow me to move the closer together, and there is a small chance that including everything between could cause a problem.

    Is there a way / formula (Without VBA) that allows me to construct an array inside a formula?

    Thanks.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,626

    Re: Creating an array from multiple, sepearated cells

    Hi
    perhaps
    Please Login or Register  to view this content.
    replace the comma with ; according to your regional settings

  3. #3
    Registered User
    Join Date
    09-22-2013
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Creating an array from multiple, sepearated cells

    Thanks, that works, but conditional formatting doesn't like it.
    Please Login or Register  to view this content.
    You may not use reference operators (such as unions, intersections, and ranges) or array constants for conditional formatting criteria.
    It doesn't like the {} in there. Any other ideas?

  4. #4
    Forum Contributor
    Join Date
    12-22-2010
    Location
    Rio, Brazil
    MS-Off Ver
    Excel 2010, 2016
    Posts
    209

    Re: Creating an array from multiple, sepearated cells

    You can create a named range, say, MyRange

    Keep pressed the Ctrl key and select H2, L2 and P2
    in the Name box, type
    MyRange
    hit Enter

    Select H2 and use the formula option in CF
    1st rule
    =H2=SMALL(MyRange,1)
    pick the format you want

    2nd rule
    =H2=SMAL(MyRange,2)
    pick the format you want

    use the Format Painter (brush) to copy the CF to L2 and P2

    Hope this helps
    Last edited by mlcb; 10-05-2013 at 03:34 AM.
    Marcelo Branco

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Creating an array from multiple, sepearated cells

    The SMALL function will accept multiple area references.

    Try it like this:

    =D2<=SMALL(($D2,$H2,$L2,$P2),2)

    EDIT: However, that syntax is still not allowed in refedits (those little boxes in userforms where you enter a formula or a range reference).

    This syntax is allowed:

    =D2<=SMALL(CHOOSE(ROW(INDIRECT("1:4")),D2,H2,L2,P2),2)

    If you test that formula in a worksheet cell it must be array entered.

    Array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Last edited by Tony Valko; 10-05-2013 at 10:48 AM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Creating an array from multiple, sepearated cells

    If you want different formats for SMALL 1 and SMALL 2 then use these formulas:

    For SMALL 1:

    =D2=MIN(D2,H2,L2,P2)


    For SMALL 2:

    =D2=SMALL(CHOOSE(ROW(INDIRECT("1:4")),D2,H2,L2,P2),2)
    Last edited by Tony Valko; 10-05-2013 at 10:50 AM.

  7. #7
    Registered User
    Join Date
    09-22-2013
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Creating an array from multiple, sepearated cells

    Well, this one (=SMALL(($D2,$H2,$L2,$P2),2)) would work, were it not for that quoted error above. It works fine in the cells, but not conditional formatting.

    That seems to be the holdup. I could just created a hidden column, but I'd prefer not to if possible.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Creating an array from multiple, sepearated cells

    Did you try this one:

    For SMALL 2:

    =D2=SMALL(CHOOSE(ROW(INDIRECT("1:4")),D2,H2,L2,P2),2)

    It should work if I understand what you want to do.

  9. #9
    Registered User
    Join Date
    09-22-2013
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Creating an array from multiple, sepearated cells

    The base function doesn't even work. And I'm not sure what you're doing to fix it. Below is the step by step evaluation.

    EVALUATE:
    SMALL(CHOOSE(ROW(INDIRECT("1:4")),D2,H2,L2,P2),2)
    SMALL(CHOOSE(ROW($1:$4),D2,H2,L2,P2),2)
    SMALL(CHOOSE(1,D2,H2,L2,P2),2)
    SMALL($D$2,2)
    #NUM!

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Creating an array from multiple, sepearated cells

    If you enter that formula in a worksheet cell it must be array entered.

    Array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Creating an array from multiple, sepearated cells

    Do you want the smallest value to be one format and the 2nd smallest value to be another format?

    What if these are the values:

    D2 = 10
    H2 = 10
    L2 = 20
    P2 = 20

    Which cell is the smallest and which is the 2nd smallest?

    Which cells should be formatted?

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Creating an array from multiple, sepearated cells

    Yes, just to clarify: formulas entered in Conditional Formatting are automatically array-entered, so no need to manually enter the curly brackets.

    Of course, as Tony points out, when entered in the worksheet, they still require the usual CTRL+SHIFT+ENTER.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  13. #13
    Registered User
    Join Date
    09-22-2013
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Creating an array from multiple, sepearated cells

    The fact that it would work in conditional formatting and not the spreadsheet is what I was missing.
    It works, thanks everybody.

  14. #14
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Creating an array from multiple, sepearated cells

    Good deal. Thanks for the feedback!

+ 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. Creating array of specialcells(visible) returns only first x cells
    By Bishonen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-27-2013, 11:04 AM
  2. Creating Array in VBA from a single row and multiple columns
    By davidWA in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-04-2012, 05:07 AM
  3. Creating an array from several seperate cells...
    By levo_redkid in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-07-2008, 09:51 AM
  4. Creating Array formulas with multiple criteria
    By Space Elf in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-15-2006, 09:30 AM
  5. [SOLVED] Creating a single vertical array from multiple column arrays
    By Bryan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2005, 03:15 PM

Tags for this Thread

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