带有公式的 Excel 2010 VBA 错误 1004
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21907106/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:03:34 来源:igfitidea点击:
Excel 2010 VBA Error 1004 with formula
提问by bumblebeeman
I have this code:
我有这个代码:
Dim fStrecke As String
fStrecke = "=A" & z & "*B" & z & "*C" & z
wks.Cells(z, "L").Formula = fStrecke
Dim fZeit As String
fZeit = "=IF(ISBLANK(H" & z & ");((A" & z & "*B" & z & "*I" & z & ")-I" & z & ")+(A" & z & "*B" & z & "*J" & z & ");(A" & z & "*B" & z & "*H" & z & "))"
wks.Cells(z, "K").Formula = fZeit
The first formula is working and for the second i get an runtime error 1004. any idea? i have formatted the column K as user defined with "m:ss".
第一个公式有效,第二个公式出现运行时错误 1004。知道吗?我已将 K 列格式化为用户定义的“m:ss”。
回答by Dmitry Pavliv
There are two options for you:
有两种选择:
- use
.FormulaLocal
property:wks.Cells(z, "K").FormulaLocal = fZeit
- use comma
,
as separator instead of semicolon;
(even if your local settings require;
as standard separator):
- 使用
.FormulaLocal
属性:wks.Cells(z, "K").FormulaLocal = fZeit
- 使用逗号
,
作为分隔符而不是分号;
(即使您的本地设置需要;
作为标准分隔符):
fZeit = "=IF(ISBLANK(H" & z & "),((A" & z & "*B" & z & "*I" & z & ")-I" & z & ")+(A" & z & "*B" & z & "*J" & z & "),(A" & z & "*B" & z & "*H" & z & "))"
wks.Cells(z, "K").Formula = fZeit