Home » excel » excel – How to copy down a formula that uses arrays?

excel – How to copy down a formula that uses arrays?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have 25000 rows of data and within them, I have 50 unique variables. Therefore, these variables are expressed 500 times (or “scenarios”)

My formula:

=IF(K2>$K$3,3,IF(K2=0,0,IF(L1=3,2,IF(COUNT($L1:L$2)>(64-$L$2-COUNTIF($K$3:$K$51,">0")),1,2))))

My formula assigns either a 3, 2, or 1 to each of the 50 variables depending on the scenario, however, it only works for one scenario.

I obviously cannot fill down this formula for all 500 scenarios. However, I need a quick way to apply this formula for all scenarios.

Is there a way to quickly do this or do I need to come up with a better formula?

How to&Answers:

Here is a formula that changes the cell reference from K3 to K53 and so on, every 50 rows. Also, the reference to K3:K51 will adjust to K53:K101 etc.

Using Index instead of Indirect, this formula is not volatile and should not cause slowness.

=IF(K2>INDEX(K:K,(CEILING(ROW(A1)/50,1)*50)-50+3),3,IF(K2=0,0,IF(L1=3,2,IF(COUNT($L1:L$2)>(64-$L$2-COUNTIF(INDEX(K:K,(CEILING(ROW(A1)/50,1)*50)-50+3):INDEX(K:K,(CEILING(ROW(A1)/50,1)*50)-50+51),">0")),1,2))))