[英]Use VBA to insert a formula in a cell
I have a function that should fill 8 rows with a formula 我有一个应该用公式填充8行的函数
Sub df_opbouwen()
num_weeks = 8 + 10
For i = 10 To num_weeks
Sheets("Blad1").Cells(i, 2).Formula = "=WEEKNUMMER(D10)"
Next i
End Sub
However, when I open the Excel, I still get a #name?
但是,当我打开Excel时,仍然会得到一个#name?
error. 错误。 That's strange because when I just enter =WEEKNUMMER(D10)
in the cell it does work. 这很奇怪,因为当我在单元格中输入=WEEKNUMMER(D10)
时,它确实起作用。
Any thoughts on what goes wrong here? 对这里出什么问题有任何想法吗?
you have a small type error: 您有一个小的类型错误:
Sub df_opbouwen()
num_weeks = 8 + 10
For i = 10 To num_weeks
Sheets("Blad1").Cells(i, 2).Formula = "=WEEKNUM(D10)"
Next i
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.