+ Reply to Thread
Results 1 to 9 of 9

Return blank when grabbing the year from the date in a different cell

  1. #1
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Smile Return blank when grabbing the year from the date in a different cell

    Cells in column B have dates in them such as 1/1/2017, etc

    I am bringing over the year only from this date into column A
    I want to ignore any blanks that there may be in column B (the column with the full date)
    Right now my formula is simple: =YEAR(B2)

    How/what do I add to this formula to ignore the blanks in column B?

    Thank you

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Return blank when grabbing the year from the date in a different cell

    Hi,

    Presumably...

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Return blank when grabbing the year from the date in a different cell

    Hello,
    I thought that would work too, but it doesn't. I checked my formatting and that isn't the issue. I am still seeing #VALUE! for the cells that are blank.
    Last edited by Hedy; 05-08-2018 at 01:03 PM. Reason: add to response

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Return blank when grabbing the year from the date in a different cell

    is it possible the item in the "blank" cell isn't really blank? For example could there be a space in the cell? Because if I hit the space bar and then point that formula at it I'll get a value error.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Return blank when grabbing the year from the date in a different cell

    Quote Originally Posted by Hedy View Post
    Hello,
    I thought that would work too, but it doesn't. I checked my formatting and that isn't the issue. I am still seeing #VALUE! for the cells that are blank.
    Please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.

    Show a before and after situation with manually calculated results, explaining which information is data and which is results, and if it's not blindingly obvious how you have arrived at your results some explanatory notes as well.

  6. #6
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Return blank when grabbing the year from the date in a different cell

    As suggested by one of the responses, the user entered N/A into the field, and that is why I am getting the #VALUE! result. The formula is perfect - thank you.

    That said, how/where would I add to this formula to leave the host cell blank if N/A is in B2?

    Original formula from Richard:

    =IF(B2="","",YEAR(B2))

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Return blank when grabbing the year from the date in a different cell

    if N/A is not the result of an error but hard coded then this modification to Richard's formula would work...
    =IF(OR(B2="",B2="N/A"),"",YEAR(B2))
    if it is the result of an error then...
    =IFERROR(IF(B2="","",YEAR(B2)),"")

  8. #8
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Return blank when grabbing the year from the date in a different cell

    Thank you both for your great help!

  9. #9
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: Return blank when grabbing the year from the date in a different cell

    You're welcome AND thank you for the rep!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 13
    Last Post: 07-14-2016, 03:46 PM
  2. [SOLVED] return value if date is between two other dates, depending on the year of another cell
    By danwoltrs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-13-2016, 11:36 AM
  3. Replies: 3
    Last Post: 10-06-2015, 05:30 PM
  4. Return True if date in cell is between a month and year in drop down comboboxes
    By Julesdude in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-25-2014, 05:18 AM
  5. [SOLVED] Date formula to return blank if cell is blank
    By DSgator1961 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-17-2014, 12:43 PM
  6. Display 'Date' cell as blank instead of default year 1900
    By charger100 in forum Excel General
    Replies: 5
    Last Post: 11-19-2009, 05:21 PM
  7. Formula to return year of date in a cell
    By mikeburg in forum Excel General
    Replies: 5
    Last Post: 03-25-2007, 05:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1