Search code examples
excelreferencerowcellformula

Expanding an Excel formula without referencing the previous cell


I am attempting to use an IF statement to check whether the sum of two cells from another Excel sheet is greater than or equal to 1.

For a sheet called Test1 with the values of interest in column C, this is what I have so far, which works fine: =IF((Test1!C1+Test1!C2>=1),1,0)

In column B on a second sheet that I'll call Test2, I want to copy this formula down 200,000 rows. However, if the aforementioned formula is in cell B1, for the formula in B2 I would like the formula to read: =IF((Test1!C3+Test1!C4>=1),1,0)

I want to copy the formula down the column so that the second cell reference in the formula in the first row does not become the first cell reference in the formula in the second row (eg. it would go C1+C2, then C3+C4, C5+C6, etc.).

I have tried manually entering the formula for a few rows, highlighting those, and copying them down but can't get the desired cell reference pattern. If I highlight and drag these first three formulae down another three rows, C4 and C5 are repeated and not in the correct pair.

=IF((Test1!C1+Test1!C2>=1),1,0)

=IF((Test1!C3+Test1!C4>=1),1,0)

=IF((Test1!C5+Test1!C6>=1),1,0)

=IF((Test1!C4+Test1!C5>=1),1,0)

=IF((Test1!C6+Test1!C7>=1),1,0)

=IF((Test1!C8+Test1!C9>=1),1,0)

I have tried using OFFSET() within this formula but couldn't get it to work. I am basically just wanting to add 1 to each of the cell references in the formula, as compared to the previous row (but not to actually add 1 to the value of that cell, as would happen with C1+1 for example).

Any insight would be greatly appreciated!


Solution

  • If you plan on copying this down 200K rows then you will want the absolute simplest formula that accomplishes the stagger. Avoid the volatile OFFSET function or be prepared to spend a lot of time waiting for random calculation cycles to complete. A volatile function will recalculate whenever anything in the workbook changes; not just when something changes that involved the formula in the cell.

     =--(SUM(INDEX(Test1!C:C, (ROW(1:1)-1)*2+1), INDEX(Test1!C:C, (ROW(1:1)-1)*2+2))>=1)