VLOOKUP MONTH & YEAR formula

ortmll

New Member
Joined
Dec 15, 2014
Messages
3
I need to update my formula so that it captures the month & year of a date.
Here is what I have now: =IFERROR(VLOOKUP(MONTH(D8),Months,2),"")

It works perfectly when all of the months are in the same year, but since the new year it is unable to differentiate between 2014 & 2015.
My gut tells me this is an easy fix, but my brain has thus far been unable to deliver:confused:.

  • D8 represents the cell containing my date.
  • "Months" represents my table containing the months of the year
  • I added the column containing the years to expand this formula, but so far it has not worked
Any help would be appreciated




Months</SPAN>

Column1</SPAN>
Column2</SPAN>
""</SPAN>
Null</SPAN>
Null</SPAN>
1</SPAN>
Jan</SPAN>
2014</SPAN>
2</SPAN>
Feb</SPAN>
2015</SPAN>
3</SPAN>
Mar</SPAN>
2016</SPAN>
4</SPAN>
Apr</SPAN>
2017</SPAN>
5</SPAN>
May</SPAN>
2018</SPAN>
6</SPAN>
Jun</SPAN>
2019</SPAN>
7</SPAN>
Jul</SPAN>
2020</SPAN>
8</SPAN>
Aug</SPAN>
2021</SPAN>
9</SPAN>
Sep</SPAN>
2022</SPAN>
10</SPAN>
Oct</SPAN>
2023</SPAN>
11</SPAN>
Nov</SPAN>
2024</SPAN>
12</SPAN>
Dec</SPAN>
2025</SPAN>

<TBODY>
</TBODY>


<TBODY>
</TBODY>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
If I were doing it, I would change the column you created to add the year to be a combination of month & year (Jan-2015 or 1-2015 or something similar). Then you can modify the VLOOKUP to be =IFERROR(VLOOKUP(MONTH(D8)&"-"&YEAR(D8),Months,2),"").

I would recommend just testing the formula =MONTH(D8)&"-"&YEAR(D8) in a random cell so that you can see what the VLOOKUP formula will be looking for, then change your "year" column to match that.
 
Upvote 0
First of all, thank you for your help!</SPAN>

I made the adjustments you suggested to my “Months” table and the formula: =MONTH(D8)&"-"&YEAR(D8) worked perfectly in my test cell.</SPAN>

Unfortunately, when I applied the formula: =IFERROR(VLOOKUP(MONTH(D8)&"-"&YEAR(D8),Months,2),"") it returned a value of “NULL” from my table.</SPAN>

Any thoughts?</SPAN>
 
Upvote 0
Is the column you added (initially as just year, then modified to be month & year) on the left side of the table? In order for VLOOKUP to work, the value you're searching for has to be in the far left of the search range.
 
Upvote 0
Is the column you added (initially as just year, then modified to be month & year) on the left side of the table? In order for VLOOKUP to work, the value you're searching for has to be in the far left of the search range.

Here is what the table looks like. the month/year is set up in the right column. However, when I moved it to the far left my formula returned a blank. No longer the "NULL" result, but at least the null was in the same column as my month/year combos.
:confused: =IFERROR(VLOOKUP(MONTH(C4)&"/"&YEAR(C4),Months,2),"")
MonthsColumn1
""Null
1Jan/2014
2Feb/2014
3Mar/2014
4Apr/2014
5May/2014
6Jun/2014
7Jul/2014
8Aug/2014
9Sep/2014
10Oct/2014
11Nov/2014
12Dec/2014
13Jan/2015
14Feb/2015
15Mar/2015
16Apr/2015
17May/2015
18Jun/2015
19Jul/2015
20Aug/2015
21Sep/2015
22Oct/2015
23Nov/2015
24Dec/2015

<TBODY>
</TBODY><COLGROUP><COL><COL></COLGROUP>
 
Upvote 0

Forum statistics

Threads
1,215,374
Messages
6,124,569
Members
449,173
Latest member
Kon123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top