我正嘗試使用.Formula將公式插入新創建的最後一個ListRows。 該代碼段工作在上一個ListRows中使用帶有變量的.Formula
oNewRow.Range(0, 2).Formula = "=IF(COUNTIF(A:A,[@PRODNAME])<=1,""100-"" & CHAR(72) & ""-0""&COUNTIF(A:A,[@PRODNAME]),)"
該公式變爲在沒有問題,但我需要的CHAR(),以由可變來表示。
謝謝。
Dim cChr As Integer
Dim tbl As ListObject
Dim tblRows As Integer
Dim oNewRow As ListRow
Set tbl = ThisWorkbook.Worksheets("100-0-00").ListObjects("TBL_tertiary129")
Set oNewRow = tbl.ListRows.Add(AlwaysInsert:=True)
tblRows = tbl.ListRows.Count
cChr = (65 + tblRows - 2) 'Increment alpha value based on position
MsgBox (Chr(cChr))
oNewRow.Range(0, 2).Formula = "=IF(COUNTIF(A:A,[@PRODNAME])<=1,""100-"" & CHAR(" & cChr & ")""-0"" &COUNTIF(A:A,[@PRODNAME]),)" 'Problem with Formula within Quotes
你得到什麼錯誤? – JNevill
1004應用程序定義或對象定義的錯誤 – James007