Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference a range using column number

Tags:

excel

formula

I'm looking for something rather simple, but I've been trying to do it for quite some time now. I need to get values from a column.

Lets say I have several columns with headers and I need to pull data from a column with a specific header. I can easily get it's number by using MATCH to look through the row with headers. Now that I have number - I need to pull say 10 cells from this column right below the header.

For example if headers are in the first row and the one I need is in the E column then I need to pull E2:E11. And I have 5 as the column number resulting from MATCH function. I would use OFFSET as it does pretty much what I need with values like this OFFSET(A1;1;MATCH(blablabla);10;1). And it works just fine, however I need to do this from a closed workbook and OFFSET only works with currently opened ones.

There's got to be a simple solution, I can't believe Excel provides a function like COLUMN but not the reversed solution. For the sake of people using the resulting workbook I can't really switch to R1C1 view but if that would be my only option, I guess that will have to do.

Please advice what I could do in this situation.

like image 635
waterplea Avatar asked Aug 22 '13 08:08

waterplea


People also ask

How do you refer to an Excel range?

In Microsoft Excel, a range is a block of two or more cells. A range reference is represented by the address of the upper left cell and the lower right cell separated with a colon. For example, the range A1:C2 includes 6 cells from A1 through C2.

How do you reference a cell row and column in Excel?

To refer to a cell, type the column letter followed by the row number. For example, D50 refers to the cell at the intersection of column D and row 50.

How do I create a column of numbers in a range in Excel?

The COLUMN function returns the column number of the given cell reference. For example, the formula =COLUMN(D10) returns 4, because column D is the fourth column.

How do you set a range to an entire column?

For example, if you want to find the sum of all of the values in column C, you would type =SUM(C:C). This kind of cell range allows you to add as much data as you want to your spreadsheet without having to update your cell ranges.


1 Answers

Try using INDEX, that should work OK with a closed workbook, syntax would be like this:

=INDEX([Book1.xls]Sheet1!$B$2:$Z$11,0,MATCH("x",[Book1.xls]Sheet1!$B$1:$Z$1,0))

That will find "x" in B1:Z1 of book1 sheet1 and then give the 10 cells below (in rows 2 to 11)

like image 113
barry houdini Avatar answered Oct 03 '22 01:10

barry houdini