How to Apply VLOOKUP by Date in Excel

The following picture gives an idea of how VLOOKUP by date works.

Vlookup by Date


Apply VLOOKUP by Date in Excel

We are going to use the following dataset to illustrate how to apply VLOOKUP by date in Excel. The dataset contains the sales amounts corresponding to different dates.

We want to enter the date in cell E5 and find the corresponding amount of sales in cell F5.

Steps

  • Enter the following formula in cell F5:
=VLOOKUP(E5,B5:C10,2,FALSE)

entering vlookup formula

  • Enter a date in cell E5 to get the desired sales amount as follows.

Vlookup by date applied successfully

You must enter the date in the same format as in the dataset which is MM/DD/YYYY in this case.

If the date you are looking for doesn’t exist in the dataset, it will show a #N/A error. For example, enter 2/4/2022 instead of 2/4/2022 and you will see the following.

How does the Formula Work?

The VLOOKUP function consists of the following arguments:

VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

It asks for the value to lookup(lookup_value). Then the range of data to look up(table_array). After that, it asks the column number(col_num_index) where the return value exists in that range. Finally, the range_lookup argument asks whether you want to look for an Approximate Match(TRUE) or an Exact Match(FALSE).

If we compare this with the formula entered in cell F5 then we get,

  • Lookup_value = E5 which contains the date we look for.
  • Table_array = B5:C10 which contains the dataset.
  • Col_index_num = 2 which is the second column of the dataset containing the sales amounts we wanted to find out.
  • Range_lookup = FALSE, meaning looking for an exact match.

Read More: How to Use VLOOKUP Function with Exact Match in Excel


Perform VLOOKUP to Return a Date in Excel

We want to find the date corresponding to the maximum sales amount.

Steps

  • Enter the following formula in cell E5:
=MAX(C5:C10)

The MAX function in this formula will return the maximum sales amount from the Sales column.

entering the MAX function

  • Enter the following formula in cell F5:
=VLOOKUP(E5,B5:C10,1,FALSE)

Vlookup by date shows #N/A error

We get an error because VLOOKUP only looks from left to right.

  • Swap the Date and the Sales columns.
  • Change the formula in cell E5 to the following:
=MAX(B5:B10)

  • Apply the following formula in cell F5:
=(VLOOKUP(E5,B5:C10,2,FALSE)

  • Change the date format of that cell from the Home tab.

changing number format in excel

  • An alternative is to apply the following formula instead of the earlier one in cell F5.
=TEXT(VLOOKUP(E5,B5:C10,2,FALSE),"D-MMM-YY")

The TEXT function in this formula will change the value obtained from the VLOOKUP formula to the date format.

entering the TEXT function

Read More: How to Use VLOOKUP to Search Text in Excel


Things to Remember

  • You must enter dates in the same format as the dates in the dataset.
  • The lookup value must be in a column earlier than the column which contains the return value.
  • Make sure the text format is inside double quotes (“”) in the TEXT function.

Download the Practice Workbook


Related Articles


<< Go Back to VLOOKUP a Range | Excel VLOOKUP Function | Excel Functions | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Shamim Reza
Md. Shamim Reza

Md. Shamim Reza, a marine engineer with expertise in Excel and a fervent interest in VBA programming, sees programming as a time-saving tool for data manipulation, file handling, and internet interaction. His diverse skill set encompasses Rhino3D, Maxsurf C++, AutoCAD, Deep Neural Networks, and Machine Learning. He holds a B.Sc in Naval Architecture & Marine Engineering from BUET and has transitioned into a content developer role, generating technical content focused on Excel and VBA. Beyond his professional pursuits,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo