一般来说
.Formula
显示了真正的英语公式。不管你的语言是什么。因此
Hoy()
应更改为
Today()
.
Cells(3, i * 2 - 1).Formula = "=BDH(A" & i * 2 - 1 & ", A1, B1, Today())"
通常,当您遇到类似“如何将工作Excel公式转换为VBA”的问题时,请执行以下操作:
-
-
-
从即时窗口中取公式,稍加修改以放入变量
i * 2 - 1
.
Public Sub PrintMeUsefulFormula()
Dim strFormula As String
Dim strParenth As String
strParenth = """"
strFormula = Selection.Formula
strFormula = Replace(strFormula, """", """""")
strFormula = strParenth & strFormula & strParenth
Debug.Print strFormula
End Sub