I'm trying to input a formula in a cell after inserting a row. And VBA does not want that and returns an error.
I first copied the formula from the excel sheet, (with ";" as delimitors), and as I have seen on other threads, I replace those with ",".
I don't understand why I get the error.
Sub Borderx()
Dim nboc As Integer
Dim ipaste As Integer
nboc = Worksheets("BDD").Range("IQ2").Value
For ipaste = 1 To nboc - 1
Worksheets("Bordereaux").Range("B14").EntireRow.Insert
Worksheets("Bordereaux").Range("T14").Formula = "=IF(AND(J14="",E14=""),SUM(F14*F14*H14)/1000,IF(O14="",SUM((H14*F14*G14)+(M14*K14*L14))/1000,SUM((H14*F14*G14)+(M14*K14*L14)+(R14*P14*Q14))/1000))"
Next ipaste
End Sub
In this case, nboc = 2, and this is supposed to insert one row. Before I added the "if" statement, it worked fine when it was just sum()
像这样更改它:
Worksheets("Bordereaux").Range("T14").Formula = " =IF(AND(J14="""",E14=""""),SUM(F14*F14*H14)/1000,IF(O14="""",SUM((H14*F14*G14)+(M14*K14*L14))/1000,SUM((H14*F14*G14)+(M14*K14*L14)+(R14*P14*Q14))/1000))"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.