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".
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.
#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.
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.
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.
There are two options for you:
.FormulaLocal
property: wks.Cells(z, "K").FormulaLocal = fZeit
,
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With