Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
e> ClientInfo表、vba或其他。只要有效,就没有正确的方法或理想的方法。我将编辑我的标题,以反映我同意@Gary的学生-您需要说明是否需要在ProjectInfo表中的D列,例如ClientInfo表中的年龄?ProjectInfo表和Clie_Vba_Excel_Excel Formula_Formula - Fatal编程技术网

e> ClientInfo表、vba或其他。只要有效,就没有正确的方法或理想的方法。我将编辑我的标题,以反映我同意@Gary的学生-您需要说明是否需要在ProjectInfo表中的D列,例如ClientInfo表中的年龄?ProjectInfo表和Clie

e> ClientInfo表、vba或其他。只要有效,就没有正确的方法或理想的方法。我将编辑我的标题,以反映我同意@Gary的学生-您需要说明是否需要在ProjectInfo表中的D列,例如ClientInfo表中的年龄?ProjectInfo表和Clie,vba,excel,excel-formula,formula,Vba,Excel,Excel Formula,Formula,e> ClientInfo表、vba或其他。只要有效,就没有正确的方法或理想的方法。我将编辑我的标题,以反映我同意@Gary的学生-您需要说明是否需要在ProjectInfo表中的D列,例如ClientInfo表中的年龄?ProjectInfo表和ClientInfo表表除了名称和公司之外,一点都不一样,这就是为什么我需要能够在匹配的ClientInfoTable中获取地址。我将在一篇社论中澄清,我个人认为,如果问题被添加了与VBA相关的标签,并且标题中注明了VBA,那么@SMeaden的任何未


e> ClientInfo表、vba或其他。只要有效,就没有正确的方法或理想的方法。我将编辑我的标题,以反映我同意@Gary的学生-您需要说明是否需要在
ProjectInfo
表中的D列,例如
ClientInfo
表中的年龄?
ProjectInfo表
ClientInfo表
表除了名称和公司之外,一点都不一样,这就是为什么我需要能够在匹配的
ClientInfoTable
中获取地址。我将在一篇社论中澄清,我个人认为,如果问题被添加了与VBA相关的标签,并且标题中注明了VBA,那么@SMeaden的任何未来问题寻求者都不会因此受益。但我来这里也不是为了成为一名负责答案的官员。它可以帮助你不认识的人。我得到赏金的唯一原因是提供一个现有的答案,如果有人满足概述的要求,我会这样做。我只是不能马上给你,所以你要等24小时才能给我实际的数量,所以我只是困在林波亚,这是VBA的一种方法,该死,我应该在提出这个问题之前录制一个宏。尽管总是只有一场比赛,但这可能会对未来的某个人有所帮助。这将是有趣的,看看是否有一个很好的公式答案,为那些不允许使用VBA文档的用户,根据公司政策等。我会给你的正确答案,因为你是第一。感谢所有不知道的人:将
应用程序设置为False。屏幕更新
为False将停止实际的动画表演这对我个人来说感觉有些过分,但并不意味着回答不好。它可以帮助很多人,特别是那些精通SQL语言的人请原谅我@soulshined,但这确实是一个典型的SQL问题,两个表之间有一个简单的
内部联接
。使用ODBC,Excel可以查询工作表内的工作表和范围,甚至可以跨工作簿查询。更快、可扩展、高效、可维护的解决方案,无需
循环或嵌套公式。这些人可以说是杀伤力过大!但每个人都有自己的选择。@Parfait我现在绝对看到了它的好处。事实上,我在这个问题后几天就看到了这些好处。哈哈,我有一个关于赏金的新问题,如果你愿意分享你的想法,我是从你的赏金那里来到这里的。您的多个匹配只是动态SQL。屏幕截图显示您使用Excel for Mac,需要。考虑学习这个有用的专用语言,其中大部分程序员在某个时候使用。@ PaFIT我非常熟悉SQL,但不熟悉VBA或语言如何共存。VBA是我2017年的新年决心,挑战自己学习一门新语言。所以我慢慢地进入了事情的核心。我在Win 10上使用2016 excel(32位),顺便说一句,我不知道为什么它看起来像Mac版本?感谢你的努力,有人击败了你,认为这是一个非常好的独特配方解决方案。我会要求你实际更改地址,因为这是我唯一的要求。但这是一个很好的选择示范。您还应该修复公式的语法-
ClientInfoTable可能会让一些新来者感到困惑。这太棒了@罗宾,非常感谢你。我真的很高兴你包括了一个VBA的答案。我真的不想使用改变接口的方法,因为在表过滤时,表旁边的数据会消失,但通过
屏幕更新
很容易避免这种情况。另外,给他打上正确的标记是很好的,因为,嗯,他没有错。当它允许我的时候,我会给你一些赏金,因为你做了我要求的一切来赢得它。这个公式太棒了,谢谢你的解释。我不知道双一元运算符!!!这周我要学习。
         A      |       B      |     C     |
  ------------------------------------------
1 |     Name    |    Company   |  Project  |
  ------------------------------------------
2 | Chris Evans |     Apple    |   Info    |
  ------------------------------------------
3 | Chris Evans |    Google    |   Info    |
  ------------------------------------------
4 | Bill Gates  |  Burger King |   Info    |
  ------------------------------------------
         A      |       B      |   C   |   D
  -------------------------------------------
1 |    Client   |    Company   |  Age  |  Sex | 
  -------------------------------------------
2 | Chris Evans |     Apple    |   12  |   M  |
  -------------------------------------------
3 | Chris Evans |    Google    |   17  |   M  |
  -------------------------------------------
4 | Bill Gates  |  Burger King |   98  |   F  |
  -------------------------------------------
=ADDRESS(ROW(INDEX(ClientInfoTable,MATCH([@[Client]],ClientInfoTable[Client],0),1)),COLUMN(INDEX(ClientInfoTable,MATCH([@[Client]],ClientInfoTable[Client],0),1)),1,1,"Clients")
Option Explicit

Sub main()
    Dim rng As Range

    With ActiveSheet.ListObjects("ClientInfoTable").Range '<--| reference 'ClientInfoTable' range
        .AutoFilter field:=1, Criteria1:="Chris Evans" '<--| filter it on its 1st column with "Chris Evans"
        .AutoFilter field:=2, Criteria1:="Google" '<--| filter it on its 2nd column with "Google"
        If Application.WorksheetFunction.Subtotal(103, .Resize(, 1)) > 1 Then
            Set rng = .Resize(.Rows.Count - 1).Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 1) '<--| if any filtered cells other than header then set the range corresponding to upleftmost filtered cell below the headers row
            MsgBox "Found at " & rng.Address
        End If
        .AutoFilter '<--| show rows back visible
    End With
End Sub
Option Compare Text
Option Explicit
Public Function doubleMatch(criteria1 As Range, criteria1_Range As Range, criteria2 As Range, criteria2_Range As Range) As Long
Dim crit1 As Variant, crit2 As Variant
Dim crit1_ARR(), crit2_ARR() 'Arrays where criteria ranges are stored
Dim i As Long, j As Long
Dim u1 As Long, l1 As Long

crit1_ARR = criteria1_Range.Value2
crit2_ARR = criteria2_Range.Value2
crit1 = criteria1.Value
crit2 = criteria2.Value

doubleMatch = -1
'checking if ranges have the same height
If (UBound(crit1_ARR) <> UBound(crit2_ARR)) Then
    GoTo endFunc
End If

'checking if ranges are one col wide
If (LBound(crit1_ARR, 2) <> UBound(crit1_ARR, 2)) Then
    GoTo endFunc
End If

If (LBound(crit2_ARR, 2) <> UBound(crit2_ARR, 2)) Then
    GoTo endFunc
End If

l1 = LBound(crit1_ARR)
u1 = UBound(crit1_ARR)

For i = l1 To u1
    If (crit1 = crit1_ARR(i, 1)) Then
        If (crit2 = crit2_ARR(i, 1)) Then
            doubleMatch = i + Abs(l1 = 0) * 1
            GoTo endFunc
        End If
    End If
Next i

endFunc:

End Function
=ADDRESS(doubleMatch(H2;A:A;I2;B:B);MATCH("Client";A:A;0))
=VLookUp(A1&","&B1, Choose({1.2}, ClientInfoTable!A1:A4&","&ClientInfoTable!B1:B4,ClientInfoTable!C1:C4), 2, False)
A-----------------------|B----------
Chris Evans, Apple      |12
Chris Evans, Google     |17
Bill Gates, Burger King |98
=Match(A1&","B1, Choose({1.2}, ClientInfoTable!A1:A4&","&B1:B4,ClientInfoTable!C1:C4))
=ADDRESS(
    ROW(
        ClientInfo
    ) - 1 +
    MATCH(
        1,
        INDEX(
            --INDEX(
                ClientInfo[Client] = $A5,
                0
            ) *
            --INDEX(
                ClientInfo[Company] = $B5,
                0
            ),
            0
        ),
        0
    ),
    COLUMN(ClientInfo)
)
Option Explicit

Sub Test()

    MsgBox GetAddressOfKey("Client", "Chris Evans", "Company", "Apple", "ClientInfo")
    MsgBox GetAddressOfKey("Client", "Chris Evans", "Company", "Google", "ClientInfo")
    MsgBox GetAddressOfKey("Client", "Bill Gates", "Company", "Burger King", "ClientInfo")

End Sub

Function GetAddressOfKey(col1 As String, val1 As String, col2 As String, val2 As String, strTable As String) As String

    Dim lst As ListObject
    Dim lr As ListRow
    Dim strAddress As String
    Dim strCandidate1 As String
    Dim strCandidate2 As String

    strAddress = ""
    Set lst = ActiveSheet.ListObjects(strTable)

    'iterate rows
    For Each lr In lst.ListRows
        'get candidate values
        strCandidate1 = Intersect(lr.Range, lst.ListColumns(col1).Range).Value
        strCandidate2 = Intersect(lr.Range, lst.ListColumns(col2).Range).Value
        'check against inputs
        If strCandidate1 = val1 And strCandidate2 = val2 Then
            strAddress = lst.Range.Cells(lr.Index + 1, 1).Address
            'quit if we find a match
            Exit For
        End If
    Next lr

    'return
    GetAddressOfKey = strAddress

End Function
Option Explicit
Option Compare Text
Public Function SearchAddress(clientName As String, company As String) As String
    Dim x As Integer
    Dim shtClients As Worksheet
    Set shtClients = Sheets("Clients") 'Clients = name of the sheet with ClientTableInfo
    x = 2

    'loop through the clients table searching for the row where the clientname and companyname is what is supplied to the function

    Do
        'Column A has ClientName of ClientTableInfo
        'Column B has companyName of ClientTableInfo
        '.............
        'Column E has Address of ClientTableInfo <-- our search target
        If shtClients.Range("A" & x).Value = clientName And shtClients.Range("B" & x).Value = company Then
            SearchAddress = shtClients.Range("E" & x).Value 'column E has the address in the clients info table
            Exit Function
        End If
        x = x + 1
    Loop Until x > shtClients.UsedRange.Rows.Count
    SearchAddress = "Not found#"
End Function
=SearchAddress(ProjectInfoTable[@Name],ProjectInfoTable[@Company])
=SearchAddress(A1,A2)