+ Reply to Thread
Results 1 to 4 of 4

VBA search array and return value

Hybrid View

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    texas usa
    MS-Off Ver
    Excel 2010
    Posts
    70

    VBA search array and return value

    Please see attached excel file. The formula only works for one value - Q
    and not for other values in column E
    Thanks Carroll
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: VBA search array and return value

    Sub zz()
    Dim d As Object, ar, br
    Set d = CreateObject("scripting.dictionary")
    ar = Range("e5:e" & [e1048576].End(3).Row)
    br = Range("i5:k" & [k1048576].End(3).Row)
    For i = 1 To UBound(br)
        For j = 1 To UBound(br, 2) - 1
            d(br(i, j)) = br(i, UBound(br, 2))
        Next
    Next
    For i = 1 To UBound(ar)
        ar(i, 1) = d(ar(i, 1))
    Next
    [g5].Resize(UBound(ar)) = ar
    End Sub

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: VBA search array and return value

    UDF

    Use in cell like
    F5:

    =LookUps(E5,$I$5:$K$9,3)

    then fill down
    To a Standard code module.
    Function LookUps(myVal As Range, rng As Range, colRef As Long)
        With rng
            LookUps = Filter(.Parent.Evaluate("transpose(if((" & rng.Columns(1).Address & "=" & myVal.Address(, , , 1) & _
                ")+(" & rng.Columns(2).Address & "=" & myVal.Address(, , , 1) & ")," & rng.Columns(3).Address & "))"), False, 0)(0)
        End With
    End Function

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,481

    Re: VBA search array and return value

    Does this array-entered** formula placed in cell F5 and copied down do what you want...

    =IFERROR(INDEX(K:K,MAX(IF(E5=$I$5:$J$9,ROW(K$5:K$9),-1))),"")

    **Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself

+ 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] Search for value in array and return specified cell
    By claireowen73 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 06-25-2014, 02:39 PM
  2. [SOLVED] Search and return value based on 3 criteria (array formula?)
    By AL1976 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-03-2014, 10:49 AM
  3. Search an array with an array and return matching value
    By cheal2 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-23-2013, 04:15 PM
  4. Need to search array and return value along with title and row values
    By wilburr in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-28-2013, 06:01 AM
  5. [SOLVED] Search array and return rows?
    By marrott2 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-25-2011, 02:11 AM
  6. Search array for text, return column #
    By Spreadsheet in forum Excel General
    Replies: 5
    Last Post: 05-09-2007, 12:30 PM
  7. Search array and return element No
    By Ron in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-17-2006, 12:35 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