[VBA] Routine will not accept my .formula statements

NessPJ

Active Member
Joined
May 10, 2011
Messages
420
Office Version
  1. 365
Hello all,

I'm trying to enter 2 formulas in a range of cells in my VBA routine but i keep getting Debug errors upon execution (Run-time error 1004: Application defined or Object defined error).

These are the lines of VBA i am trying to use:
Code:
    Range("K2").Formula = "=TIME(IF(Roundup(L2*24;0)+3>=24;23;Roundup(L2*24;0)+3);0;0)" 


    Range("I2").Formula = "=IF((HOUR(L2)+24)-(HOUR(K2)-1)>=Par!$B$32;30;(HOUR(L2)+24)-(HOUR(K2)-1))"

I can paste both formulas into a cell and they will work fine. Am i using some wrong syntax somewhere? :)
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hello,

Replace semicolons with comma.

Your language settings is likely using semicolon as the parameter separator, but when you create a formula through VBA, you need to use comma.

Hope it helps.

Suat
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,641
Members
449,461
Latest member
kokoanutt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top