Gilbfernandes

New Member
Joined
Jan 26, 2016
Messages
20
Hi Everyone,

I'm trying to enter a formula in a given cell indicated by Range("P" & LastRow + 1), but for some reason it's not working.
If I enter the formula manually at the range, it works perfectly. That is the formula :

=IFERROR(IF(O65>0, _
IF('56'!$E$11=3000,DAYS360(TODAY(),O65+12*30), _
IF('56'!$E$11=3500,DAYS360(TODAY(),O65+14*30), _
IF('56'!$E$11=4000,DAYS360(TODAY(),O65+16*30), _
IF('56'!$E$11=4500,DAYS360(TODAY(),O65+18*30), _
IF('56'!$E$11=5000,DAYS360(TODAY(),O65+20*30), _
IF('56'!$E$11=5500,DAYS360(TODAY(),O65+22*30), _
IF('56'!$E$11=6000,DAYS360(TODAY(),O65+24*30),"")))))))),"")

The way I am entering it with VBA is:

Range("P" & LastRow + 1) = "=IFERROR(IF(O" & LastRow + 1 & ">0," _
& "IF('" & LinkNumber & "'!$E$11=3000,DAYS360(TODAY(),O" & LastRow + 1 & "+12*30)," _
& "IF('" & LinkNumber & "'!$E$11=3500,DAYS360(TODAY(),O" & LastRow + 1 & "+14*30)," _
& "IF('" & LinkNumber & "'!$E$11=4000,DAYS360(TODAY(),O" & LastRow + 1 & "+16*30)," _
& "IF('" & LinkNumber & "'!$E$11=4500,DAYS360(TODAY(),O" & LastRow + 1 & "+18*30)," _
& "IF('" & LinkNumber & "'!$E$11=5000,DAYS360(TODAY(),O" & LastRow + 1 & "+20*30)," _
& "IF('" & LinkNumber & "'!$E$11=5500,DAYS360(TODAY(),O" & LastRow + 1 & "+22*30)," _
& "IF('" & LinkNumber & "'!$E$11=6000,DAYS360(TODAY(),O" & LastRow + 1 & "+24*30),"")))))))),"")"

But it is not working. Could someone tell me why it is not working ???

Thank you.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
These quotes
Code:
),"")))))))),"")"
need to be doubled up
Code:
),"""")))))))),"""")"
, also add
Code:
.Formula
to the end of the range
Code:
Range("P" & LastRow + 1).Formula
 
Upvote 0
Firstly, (I think) your formula could be condensed to:
PHP:
=IF(AND('56'!$E$11>=3000,'56'!$E$11<=6000,MOD('56'!$E$11,500)=0),DAYS360(TODAY(),O65+(12+('56'!$E$11-3000)/500*60)),"")

Secondly, the double quotes in the final argument of the IF function need to be doubled up.
 
Upvote 0
These quotes
Code:
),"")))))))),"")"
need to be doubled up
Code:
),"""")))))))),"""")"
, also add
Code:
.Formula
to the end of the range
Code:
Range("P" & LastRow + 1).Formula

Thanks Fluff, it worked now.


Thanks njimack, I will try your idea for sure, it would be much simpler like this.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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