发布网友 发布时间:2022-04-24 23:40
共1个回答
热心网友 时间:2022-05-25 15:42
d2用数据有效性引用c列
c列用去重公式
e列用自定义公式
'自定义公式-按ALT+11-插入-模块(2列查询合并)
Function quchong(a As Range, b As String)
For i = 1 To 10000
If InStr(t, a.Cells(i, 1)) = 0 Then t = t & "," & a.Cells(i, 1)
If a.Cells(i, 1) = "" Then Exit For
Next
arr = Split(Right(t, Len(t) - 1), ",", -1, 1)
quchong = arr(b)
If quchong = "" Then quchong = ""
End Function
'2列查询多行显示
Function o(c As String, a As Range, b As Range, d As String)
Calculate '重算表格
'c_ = "$" & Left(c.Address, 1) & "$" & Right(c.Address, 1)
Dim t As String
Dim arr(1 To 6000, 1 To 1)
n = 1
If a.Rows.Count <> b.Rows.Count Then o = "错误": Exit Function
If c = "" Then
o = ""
Else
Set Ra = a.Find(c)
If Not Ra Is Nothing Then
For i = 1 To a.Rows.Count
If a.Cells(i, 1) = c Then
arr(n, 1) = b.Cells(i, 1)
n = n + 1
End If
If a.Cells(i, 1) = "" Then Exit For
Next
o = arr(d, 1)
If o = "" Then o = ""
Else
o = ""
End If
End If
Calculate
End Function