简体   繁体   中英

Excel 2010 VBA Error 1004 with formula

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".

There are two options for you:

  1. use .FormulaLocal property: wks.Cells(z, "K").FormulaLocal = fZeit
  2. use comma , as separator instead of semicolon ; (even if your local settings require ; as standard separator):

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 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM