引用评估和索引匹配的下一行

时间:2018-05-18 02:18:23

标签: vba excel-vba excel

我有这个公式

Dim lastrow As Long
lastrow = Sheets("Tab 1").Range("A" & Rows.Count).End(xlUp).Row

With Range("AP2:AP" & lastrow)

.Value = Evaluate("=IFERROR(INDEX('Usages'!A:G,MATCH(1,('Usages'!F:F=""No"")*('Usages'!C:C=N2)*('Usages'!D:D<=AO2)*('Usages'!E:E>=AO2),0),2),""Not Found"")")

End With

如何制作它以使我的匹配功能引用下一行 例如N2,N3AO2,AO3 目前我只得到基于N2和AO2参数的整个列的值。

此公式与Usages分开放置。

非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

尝试,

dim ulr as long, lastrow As Long

lastrow = Sheets("Tab 1").Range("A" & Rows.Count).End(xlUp).Row

with worksheets("Usages")
    ulr = .cells(.rows.count, "B").end(xlup).row
end with

With Worksheets("Tab 1").Range("AP2:AP" & lastrow)
    .Formula = "=IFERROR(INDEX('Usages'!B:B, AGGREGATE(15, 6, ROW($1:$" & ulr & ")/" & _
                   "(('Usages'!F$1:F$" & ulr & "=""No"")*('Usages'!C$1:C$" & ulr & "=N2)*('Usages'!D$1:D$" & ulr & "<=AO2)*('Usages'!E$1:E$" & ulr & ">=AO2)), 1)), ""Not Found"")"
    .Value = .Value
End With