簡體   English   中英

使用Cells.Range在Excel中插入Vlookup公式時出錯

[英]Error Inserting Vlookup Formula in Excel using Cells.Range

任何人都可以在下面的以下代碼上為我提供幫助? 我正在嘗試在工作表中插入Vlookup公式。 但是,我得到了錯誤

應用程序定義或對象定義的錯誤

Sub WriteFormulasInSheet()

Dim lRow As Long


    lRow = Cells(Rows.Count, 1).End(xlUp).Row

    Sheets("Consolidator").Activate
    Cells.Range(Cells(5, 4), Cells(lRow, 4)).Value = "=IFERROR(VLOOKUP(RC[-3],MAP!$N:$P,2,0),"""")"


End Sub

我在代碼中錯過了什么? 非常感謝您的回復。

您應該使用公式,而不是值。

Cells.Range(Cells(5, 4), Cells(lRow, 4)).FormulaR1C1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM