Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

vba - Error 400 when writing variant with excel Function to listobject

I'm getting very cofused. I'm assigning some data to a variant(vOrderdata) and then printing the variant to a new table row. Everything works out, but when If I add the formula to vorderdata(7) I get error 400. The code still works, but it raises an error 400. Should I just capture the error and ignore it or is there actually something wrong?

    Dim vOrderData(1 To 9) As Variant
    Set loorder = Worksheets("Orderhantering").ListObjects("tblOrderdata")
    vOrderData(1) = lOrdernumber
    vOrderData(2) = sSuppliernumber
    vOrderData(3) = sProjectnumber
    vOrderData(4) = Date
    vOrderData(5) = wsS.range("C15").Value
    vOrderData(6) = "Genererad"
    vOrderData(7) = "=SUMIF(Orderhistorik!I:I;[@Ordernr];Orderhistorik!F:F)"
    loorder.ListRows.Add
    lLastRow = loorder.DataBodyRange.rows.Count
    loorder.ListRows(lLastRow).range.Value = vOrderData
    Exit Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...