Script/macro 搜索查找值对(在列的 D、E 中)是否存在于查找数组(在列的 A、B 中)
Script/macro that searches if the lookup value pair (in column's D,E) exists in lookup array (in column's A,B)
Script/macro 搜索查找值对(在列的 C、D 中)是否存在于查找数组(在列的 A、B 中)。
我遇到了 MATCH
VLOOKUP
但他们只查找一个值,但我想要的是如下内容。
请注意:A 列始终按排序顺序排列
A B C D E F
_______________________________________________________________________
BOB 100 details1 CCA 100 print "False"
BOB 200 details2 DBA 100 print "False"
BOB 300 details3 BOB 100 print "details1"
CCA 500 details4 BOB 500 print "False"
作为F1
中的数组公式
同时按下CTRL+SHIFT+ENTER
=INDEX($C:$C,MATCH(D1&E1,$A:$A&$B:$B,0))
我假设您正在分别比较 D&E 列和 A 列和 B 列,当两个列匹配时,您将在第 6 列中针对匹配的一组值打印第 3 列值。
Sub macro()
Dim a, x, y As Integer
a = 1
Cells(a, 4).Select
Do While ActiveCell.Value <> ""
x = ActiveCell.Value
y = ActiveCell.Offset(0, 1).Value
Cells(1, 1).Activate
Do While ActiveCell.Value <> ""
If ActiveCell.Value = x Then
If ActiveCell.Offset(0, 1).Value = y Then
Cells(a, 6) = ActiveCell.Offset(0, 2).Value
End If
End If
ActiveCell.Offset(1, 0).Activate
Loop
a = a + 1
Cells(a, 4).Select
Loop
End Sub
希望对您有所帮助!
Script/macro 搜索查找值对(在列的 C、D 中)是否存在于查找数组(在列的 A、B 中)。
我遇到了 MATCH
VLOOKUP
但他们只查找一个值,但我想要的是如下内容。
请注意:A 列始终按排序顺序排列
A B C D E F
_______________________________________________________________________
BOB 100 details1 CCA 100 print "False"
BOB 200 details2 DBA 100 print "False"
BOB 300 details3 BOB 100 print "details1"
CCA 500 details4 BOB 500 print "False"
作为F1
同时按下CTRL+SHIFT+ENTER
=INDEX($C:$C,MATCH(D1&E1,$A:$A&$B:$B,0))
我假设您正在分别比较 D&E 列和 A 列和 B 列,当两个列匹配时,您将在第 6 列中针对匹配的一组值打印第 3 列值。
Sub macro()
Dim a, x, y As Integer
a = 1
Cells(a, 4).Select
Do While ActiveCell.Value <> ""
x = ActiveCell.Value
y = ActiveCell.Offset(0, 1).Value
Cells(1, 1).Activate
Do While ActiveCell.Value <> ""
If ActiveCell.Value = x Then
If ActiveCell.Offset(0, 1).Value = y Then
Cells(a, 6) = ActiveCell.Offset(0, 2).Value
End If
End If
ActiveCell.Offset(1, 0).Activate
Loop
a = a + 1
Cells(a, 4).Select
Loop
End Sub
希望对您有所帮助!