在插入的公式中放置一个variables

循环已经到位,但我似乎无法得到用正确的variablesreplaceA2的语法。

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$13:$D$62,MATCH(A2,MatList!$A$13:$A$62,0))" End If Next 

只需将您的公式replace为:

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

至:

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

谢谢你。 越来越近。 似乎我现在处于一个悖论中,尽pipevariables“x”同时具有0和6的值。 好奇