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