Lets look at the two functions which sound similar but give different results. COLUMN gives the position of the column and COLUMNS counts the number of columns in a range.
Let's see the syntax.
COLUMN([reference])
COLUMNS(array)
ExamplesCOLUMN(F2) = 6
COLUMN() = will give the column position of the cell where the function is.
COLUMNS(F10:I14) = 4
One use of the COLUMN function is with VLOOKUP.
Consider the example below, A table of outputs of different machines in different days.
Now I want to pull only machine 3 data to another place using VLOOKUP. First I key in Machine 3 in A6 for this example.
I need the values in column I to L to appear in column B to E.
I can key in =VLOOKUP($A6,$H:$L,2,FALSE) in B6, =VLOOKUP($A6,$H:$L,3,FALSE) in C5 and so on.
But I need to keep changing the col_index_num for every column. If you are working with a large table it can be tedious work.
Here we can use column function to make it automatic when we drag the function. The formula looks like this,
in B6 =VLOOKUP($A6,$H:$L,COLUMN(I:I)-7,FALSE)
COLUMN(I:I)-7 = 2
When you drag the function,
in C6 =VLOOKUP($A6,$H:$L,COLUMN(J:J)-7,FALSE)
in D6 =VLOOKUP($A6,$H:$L,COLUMN(K:K)-7,FALSE)
in E6 =VLOOKUP($A6,$H:$L,COLUMN(L:L)-7,FALSE)
You can use COLUMNS(A:G) instead of 7
=VLOOKUP($A6,$H:$L,COLUMN(I:I)-COLUMNS(A:G),FALSE)
Depending on the table location and where you want to pull the data the function for col_index_num will change.
Please let me know comments/feedback.