Excel – How to return multiple columns in excel

microsoft excelworksheet-function

I want to do the following:
I have two sheets with the following data. And, I want to bring over columns 3 and 4 from Sheet2 over to Sheet1. The vlookup function will only allow me to bring over 1 column of data at a time. Is there a way to bring both columns at once?

SHEET 1

Student     ISS OSS Total
John Doe    2       2
Mark Doe    2   1   3
Steven Doe  2   1   3
Kevin Doe       2   2

SHEET 2

Name        Grade  Admin        Counselor
John Doe    9      McPherson    Gildea
Mark Doe    9      McPherson    Gildea
Steven Doe  9      Bagoly       Trudell
Kevin Doe   11     McPherson    Gildea

Best Answer

You can do this by entering the column argument in VLOOKUP as an array constant. For example:

Sheet1!E2:   =VLOOKUP(A2,Sheet2!$A$2:$D$5,{3,4},FALSE)

Enter this in E2. Then Select E2:F2 and confirm by holding down ctrl + shift while hitting Enter.

The formula returns the array: {"McPherson","Gildea"} and entering it exactly the way I described returns the results into the two different cells.

You can then select E2:F2 and fill down as far as necessary.

Look at Excel HELP for information on Array Formulas and Array Constants.

Note that if you do this correctly, in the formula bar the formulas will appear the same in both E2 and F2; and also there will be braces {...} around the entire formula. Although you enter the braces when you type in the array constant {3,4} within the formula, Excel will add the braces that appear around the entire formula, when you enter a formula with the ctrl+shift+enter key combination.

enter image description here

Related Question