For Each和If函数中的FormulaR1C1

时间:2019-06-14 12:15:35

标签: excel vba excel-formula

我将宏测试一些值,并根据结果使用特定公式。我使用For EachIf控制结构的实现并没有使我达到预期的结果。该公式无法正常工作,而是出现运行时错误。

Dim RelRowR As Range

Set RelRowR = ActiveSheet.Cells(2, 1).Resize(LR1,1).SpecialCells(xlCellTypeVisible)

For Each RelRowR In RelRowR
  If RelRowR.Value = "C1" Then
     RelRowR.Offset(0, 17).FormulaR1C1 = "=IFERROR(HLOOKUP(R[0]C[-15],'[SD Workbook.xlsx]Sheet1'!R5C19:R15C31,VLOOKUP(R[0]C[-3],'[SD Workbook.xlsx].Sheet1'!R36C4:39C5,2,0),0)"
  End If
Next RelRowR

0 个答案:

没有答案