IF Function strange bug

Merlini

New Member
Joined
May 24, 2018
Messages
10
Hi all,

Iam trying to autofill an Excel and the following code gives a strange fault:

ActiveWorkbook.ActiveSheet.Range("T2:T50").FormulaR1C1 = "=IF((RC[-9])>(R[-1]C[-9]), RC[-2], RC[-1])


The formula isn't correct on row 10, 20, 30 and so on because it uses row 1, 2, 3 and so on.
Any one of You knows why this is? Or has a solution?

Thanks in advance!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
What exactly is wrong with the formula in row 10?
I get K10 > K9 which I would expect
 
Upvote 0
The formula in row 10 becomes:

=IF((K1)>(K9); R1; I1)

All where 10 should be there is a 1.
 
Upvote 0
This is what I get
=IF((K10)>(K9), R10, S10)
If you run that one line of code on a new (blank) sheet what do you get?
 
Upvote 0
Then I get the good formula indeed. Strange. I'll start in a new sheet. Thanks for helping!
 
Upvote 0
Glad to help & thanks for the feedback.
Might be worth checking if you have any event code on the sheet, that could be messing up the formula.
 
Upvote 0
I found my mistake. Before the formula I changed all the "0" in "". Now I do that afterwards.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,370
Members
449,080
Latest member
Armadillos

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