+ Reply to Thread
Results 1 to 7 of 7

Formula for Returning an Array

  1. #1
    Registered User
    Join Date
    09-20-2018
    Location
    Los Angeles, California
    MS-Off Ver
    MSO 365 ProPlus
    Posts
    4

    Formula for Returning an Array

    I have a large residential project where I need to split out aspects of each unit type across multiple buildings. For simplicity sake, I have unit types A, B, and C that have 2, 3, and 5 bedrooms respectively. I need to find out how many bedrooms are in Buildings X, Y, and Z knowing there are so many of each unit in each building as shown in the tables below:

    Unit Type A Unit Type B Unit Type C Building X Building Y Building Z
    Bedrooms 2 3 5 x y z
    # of Unit Types per Building Building X Building Y Building Z
    Unit Type A 20 30 40
    Unit Type B 10 25 60
    Unit Type C 5 20 10

    I've tried all manner of sumproduct, vlookup, hlookup, row, column, mmult, match, and index formulas to find the number of bedrooms in each building based on referencing the two tables and have had no luck. I am hoping someone here might be able to help me.

    The best I understand it, to find (x,y,z) I need some sort of array formula that references how many bedrooms are in each unit type and how many unit types are in each building. The closest I got was with this formula in cell E2 for the building X bedrooms:

    =SUMPRODUCT(B2:D2,VLOOKUP(TRANSPOSE(B1:D1),A4:D7,MATCH(E1,A4:D4,0),FALSE))

    But I don't think it works because I can't seem to get the vlookup function to return an array. I'm also not sure if it did return an array it would work with the sumproduct.

    Can vlookup return an array? If not, is there some other function I should be using?

    I'm also new to this forum so let me know if I've not framed this question properly.

    Please and Thank You.
    Last edited by Zavala; 09-20-2018 at 07:27 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Formula for Returning an Array

    Hi, welcome to the forum

    So you are looking for something like...
    Bx Ta = 40 (20*2)
    Bx Tb = 75 (25*3)
    ?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    09-20-2018
    Location
    Los Angeles, California
    MS-Off Ver
    MSO 365 ProPlus
    Posts
    4

    Re: Formula for Returning an Array

    Quote Originally Posted by FDibbins View Post
    Hi, welcome to the forum

    So you are looking for something like...
    Bx Ta = 40 (20*2)
    Bx Tb = 75 (25*3)
    ?
    In what I think that format means, I'm looking for:
    Bx Ta = 40 (20*2)
    Bx Tb = 30 (10*3)
    Bx Tc = 25 (5*5)

    So the total number of bedrooms in Building X would be 95 (40+30+25).

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Formula for Returning an Array

    Try this as in E2 and fill across to G2 as below.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    or alternatively this formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.





    A
    B
    C
    D
    E
    F
    G
    1
    Unit Type A
    Unit Type B
    Unit Type C
    Building X
    Building Y
    Building Z
    2
    Bedrooms
    2
    3
    5
    95
    235
    310
    3
    4
    # Unit types
    per Bldg
    Building X
    Building Y
    Building Z
    5
    Unit Type A
    20
    30
    40
    6
    Unit Type B
    10
    25
    60
    7
    Unit Type C
    5
    20
    10
    Last edited by FlameRetired; 09-20-2018 at 07:20 PM.
    Dave

  5. #5
    Registered User
    Join Date
    09-20-2018
    Location
    Los Angeles, California
    MS-Off Ver
    MSO 365 ProPlus
    Posts
    4

    Re: Formula for Returning an Array

    Nevermind, I have figured it out. Instead of vlookup, I used hlookup and it worked.

    So for a formula in E2, I used this:

    =SUMPRODUCT(B2:D2,HLOOKUP(E1,A4:D7,MATCH(B1:D1,A4:A7,0),FALSE))

    and confirmed with CTRL + SHIFT + ENTER.

    When I put in the proper $ marks into the formula:

    =SUMPRODUCT($B2:$D2,HLOOKUP(E$1,$A$4:$D$7,MATCH($B1:$D1,$A$4:$A$7,0),FALSE))

    I was able to copy it over to F2 and G2.

  6. #6
    Registered User
    Join Date
    09-20-2018
    Location
    Los Angeles, California
    MS-Off Ver
    MSO 365 ProPlus
    Posts
    4

    Re: Formula for Returning an Array

    Oh those work too!

    Sorry, I posted my other comment before I refreshed the page so I didn't see this.

    Thank you!

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Formula for Returning an Array

    An afterthought.

    Lay out the individual bedroom counts in E5:G7 with
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and then in E2 filled across G2
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    A
    B
    C
    D
    E
    F
    G
    1
    Unit Type A
    Unit Type B
    Unit Type C
    Building X
    Building Y
    Building Z
    2
    Bedrooms
    2
    3
    5
    95
    235
    310
    3
    4
    # Unit types
    per Bldg
    Building X
    Building Y
    Building Z
    5
    Unit Type A
    20
    30
    40
    40
    60
    80
    6
    Unit Type B
    10
    25
    60
    30
    75
    180
    7
    Unit Type C
    5
    20
    10
    25
    100
    50

+ 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. INDEX array formula returning same value
    By katieshields in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-18-2014, 11:33 AM
  2. Array Formula NOT Returning All Desired Results
    By HB333 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2014, 06:43 AM
  3. Returning an array from address formula
    By cabecar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-26-2012, 01:41 AM
  4. [SOLVED] Stumped with Formula Array returning cell adjacent to formula dataset
    By Giles_Silver in forum Excel General
    Replies: 5
    Last Post: 06-04-2012, 12:18 AM
  5. Replies: 1
    Last Post: 02-18-2012, 01:32 AM
  6. [SOLVED] Array formula returning wrong results
    By TUNGANA KURMA RAJU in forum Excel General
    Replies: 1
    Last Post: 11-19-2005, 06:35 AM
  7. Array formula returning #N/A when inserting new rows.
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2005, 06:05 AM
  8. Array formula returning terminated employees
    By malik641 in forum Excel Formulas & Functions
    Replies: 59
    Last Post: 09-06-2005, 07:05 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