Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 332
bumblebeeman Avatar asked Feb 20 '14 11:02

bumblebeeman


People also ask

What is error 1004 in VBA?

VBA Error 1004 – Object Not Found This tutorial will explain the VBA Error 1004- Application-Defined or Object-Defined Error. VBA run time error 1004 is known as an Application-Defined or Object-Defined error which occurs while the code is running.

What is VBA runtime error 1004 activate method range class failed?

#6 – VBA Runtime Error 1004 Activate method range class failed: This error occurs mainly due to activating the range of cells without activating the worksheet. For example, look at the below code.

Why do I get run time error 1004?

But if I mention the named range wrongly, I will get Run Time Error 1004: Method “Range” of object’ _ Global’ failed. Run this code manually or using the F5 key and see the result. This usually occurs when we try to select the cells other than the active sheet without making the sheet select or active.

What is “the name is already taken” error 1004?

This error occurs while renaming the sheet. If the name of the worksheet already exists and if you try to assign the same name to another sheet, VBA throws Run Time Error of 1004 stating “The Name is Already Taken.


Video Answer


1 Answers

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
like image 126
Dmitry Pavliv Avatar answered Oct 19 '22 04:10

Dmitry Pavliv