如果要查找多个匹配结果,则使用索引小的应用程序功能

时间:2019-07-11 11:44:33

标签: excel vba

Sub IndMat()
Dim wh1 As Worksheet
Dim wh2 As Worksheet
Set wh1 = Sheets("DATA")
Set wh2 = Sheets("Dashboard")
Dim y As Variant
Dim x As Long
Dim lr1 As Long
Dim lr2 As Long
Dim rng1 As Range
Dim rng2 As Range
Dim i As Integer
‘This is the formula I want to use but in an application function ‘”=IFERROR    (INDEX(DATA!$B$2:$B$257;SMALL(IF(DATA! $D$2:$D$257=DATAMATCH!$M$7;ROW(DATA!$D$2:$D$257)-MIN(ROW(DATA!$D$2:$D$257))   +1);ROWS($B$13:$I15)));"")”
 Lr1 = wh1.Cells(Rows.Count, 5).End(xlUp).Row
  Lr2 = wh2.Cells(Rows.Count, 2).End(xlUp).Row

Set rng1 = wh1.Range("D2:D" & lr1)
Set rng2 = wh2.Range("A2:A" & lr1)
For i = 2 To lr2
 wh2.Cells(i, 13) = Application.Index(rng2, Application.Small(Application.if  (rng1 = wh2.Cells(12, 1), Application.Row(rng1), Application.Min(Application.Row(rng1)) + 1), Application.Rows("B13")), "")
Next
End Sub

种类繁多的使用应用程序功能的新手,如果有人可以帮助我将此功能转换为应用程序功能,我们将非常高兴。

0 个答案:

没有答案