在插入的公式中放置变量

Placing a variable within an inserted formula

循环已经到位,但我似乎无法获得用正确变量替换 A2 的语法。

For Each c In rng1
    If WorksheetFunction.CountIf(rng2, c.Value) = 0 Then
        sh3.Cells(Rows.Count, 1).End(xlUp)(2) = c.Value
        sh3.Cells(Rows.Count, 2).End(xlUp)(2).Formula = _
            "=INDEX(MatList!$D:$D,MATCH(A2,MatList!$A:$A,0))"
    End If
Next

只需替换您的公式:

"=INDEX(MatList!$D:$D,MATCH(A2,MatList!$A:$A,0))"

收件人:

"=INDEX(MatList!$D:$D,MATCH(" & YourVariableName & ",MatList!$A:$A,0))"

谢谢你。越来越近。尽管变量 "x" 同时具有 0 和 6 的值,但我现在似乎陷入了悖论。 curious