Excel – Create a reference to a whole column in Excel through a formula

microsoft excelmicrosoft-excel-2010worksheet-function

I have a spreadsheet where I need a reference to a whole column. The catch is that I don't know which column ahead of the time, so I use MATCH function to find that out. Once I find the right column I need to reference cells in it.

Two problems stop me from using something simple like CHOOSE function instead:

  • I have couple hundreds of columns that could be referenced
  • I need to reference whole column simply, because the amount of rows is varying as well

Originally I was thinking about using MATCH, ADDRESS , INDIRECT, but ADDRESS requires me to specify rows as well. Then I thought I could use MATCH and CODE, but my formula for columns with multiple letters was buggy.

How do I achieve this? (Reference whole column based on a lookup/match.)

Best Answer

To just clarify Mureinik's answer a little bit, because it's a good start, for column MyColumn you could use: OFFSET($A$1,0,MyColumn-1,ROWS($A:$A),1)

Start at $A$1, and then offset by 0 rows and (your column number minus 1), using a height of ROWS($A:$A) and a width of 1. Max rows in recent versions is 1,048,576. You can use a smaller height if you know what the maximum height is likely to be.

So to sum column 3:

=SUM(OFFSET($A$1,0,3-1,ROWS($A:$A),1))

The answer from sgp667 is not bad, but note that SUBSTITUTE could be a little messy and slow if you are using it a lot.

To reference another sheet, just change the reference to $A$1, so for instance: SUM(OFFSET(Sheet2!$A$1,0,3-1,ROWS($A:$A),1))

Related Question