Use VLOOKUP and COLUMNS Function together in Excel

Managing data across multiple workbooks in Excel can be a challenging task, but with powerful functions like VLOOKUP and COLUMNS, you can seamlessly pull data from one workbook to another. This article will guide you through the steps to use these functions effectively to retrieve and organize data efficiently.

Understanding VLOOKUP and COLUMNS Functions

VLOOKUP (Vertical Lookup):

VLOOKUP is used to search for a specific value in the first column of a table or a range and returns a value in the same row from a column you specify. It’s great for looking up and retrieving data in vertical tables.

  =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
  • lookup_value: The value you want to search for.
  • table_array: The range of cells in which to search for the lookup value.
  • col_index_num: The column number (from the left) that contains the data you want to retrieve.
  • range_lookup: TRUE for an approximate match, FALSE for an exact match.

COLUMNS

The COLUMNS function returns the number of columns in an array or reference. It is useful for dynamically selecting columns when using VLOOKUP.

  =COLUMNS(array)
  • array: The range of columns you want to count.

Step-by-Step Guide: Using VLOOKUP and COLUMNS to Retrieve Data Across Workbooks

Scenario:

You have two workbooks:

  • Source Data: The source data is stored here.
  • Data to Populate: You need to pull specific data from Source Data into this workbook.

Step 1: Prepare the Workbooks

  1. Open both workbooks: Ensure Source Data (source) and Data to Populate (destination) are both open.
  2. Identify the data to be retrieved: In Source Data, locate the table or data range from which you want to pull information. Make sure the data is organized in a table format where the first column contains unique identifiers or lookup values.

Step 2: Use VLOOKUP and COLUMNS to Get Data

  1. Select the cell in Workbook B where you want to retrieve the data.
  2. Enter the VLOOKUP formula as follows:
   =VLOOKUP($B4,'[Source Data.xlsx]Purchase Details'!$B$3:$N$14,COLUMNS($B$3:C$3),FALSE)
  • B4: The cell in Data to Populate containing the value you want to look up (lookup_value).
  • [Source Data.xlsx]Purchase Details'!$B$3:$N$14: The table array in Source Data from which you want to retrieve the data. Ensure that you provide the full reference to the other workbook, including the workbook name, sheet name, and range.
  • Use Columns function to dynamically get the column Index number. (Step 3)
  • FALSE: This ensures that VLOOKUP finds an exact match.

How COLUMNS Function Works for Dynamic Column Reference

If you need to pull data from multiple columns and want to avoid manually counting the column index each time, you can use the COLUMNS function.

Let’s say you want to dynamically pull data from multiple columns using VLOOKUP in Data to Populate. Here’s how you do it:

  1. Instead of hardcoding the column index number, use the COLUMNS function:
   COLUMNS($B$3:C$3)

In this case, COLUMNS($B$3:C$3) returns the number of columns between B and C, which is 2. This dynamically adjusts when you drag the formula across to retrieve data from subsequent columns (D, E, etc.).

Step 3: Drag the Formula to Retrieve Data from Multiple Rows

Once the formula is working in one cell, you can easily apply it to other cells by dragging the formula to right to retrieve additional data.

Conclusion

Using the VLOOKUP function combined with the COLUMNS function provides a powerful way to extract data from one workbook to another. This method simplifies cross-workbook lookups and ensures that your data is always up-to-date and organized.

Download Practice Workbook

Download the Practice workbook files to learn these functions.

Video Tutorial

Watch the video tutorial for the step-by-step guideline on using VLOOKUP and COLUMNS function together.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top