Excel 2010 VBA Error 1004 with formula

12,648

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
Share:
12,648
bumblebeeman
Author by

bumblebeeman

Updated on June 11, 2022

Comments

  • bumblebeeman
    bumblebeeman almost 2 years

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

  • BjörnBogers
    BjörnBogers over 7 years
    What a joke! I've been looking for this solution for quite a time .. The separator from my local settings is ; so that's what I used in my code..