+ Reply to Thread
Results 1 to 8 of 8

Formula to exclude year when using look up

  1. #1
    Registered User
    Join Date
    10-19-2017
    Location
    Veteli, Finland
    MS-Off Ver
    2016
    Posts
    3

    Formula to exclude year when using look up

    I am trying to create a bill for a local hotel where they have different prices depending on the time of year. For example between 15.4. and 15.8. are the summer prices and 16.8 -14.4 the winter prices

    I have it set up so that when the room is selected it looks up the price from the corresponding list. However it is using the year also and will therefore only work for this years booking.

    It is set to look up the corresponding rooms from different lists depending on time of year, the lists are as below.

    Summer price 15.4. 15.8.
    1hh 79,00 €
    2hh 109,00 €
    2hh+sauna 119,00 €
    Apartment 5hh 230,00 €


    Winter price 16.8. 14.4.
    1hh 69,00 €
    2hh 89,00 €
    2hh+sauna 101,00 €
    Apartment 5hh 210,00 €

    The formula I am using at is,

    =IFERROR(IF(AND(B11>=Sheet2!$B$1;B11<=Sheet2!$C$1);VLOOKUP(A11;Sheet2!$A$2:$B$6;2);VLOOKUP(A11;Sheet2!$A$9:$B$13;2));"")

    It works unless I go over this year. Is there a way it can be set to ignore the year? or is it a case of changing the parameter year when it changes to 2018? or will it automatically change it, since I did not enter a year on the look up inputs but it automatically entered 2017 when the cell was formatted to a date, even in just day and month style?

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Formula to exclude year when using look up

    Hello and welcome to the forum.

    If you upload a sample workbook along with the desired results of a formula (manually entered), I'm sure we'll be able to help you with this.

  3. #3
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to exclude year when using look up

    you can try this:
    for the visual Summer/Winter: =IF(AND(NOW()>=DATE(YEAR(NOW()),4,15),NOW()<=DATE(YEAR(NOW()),8,16)),"Summer","Winter")
    for the prices: =IF(AND(NOW()>=DATE(YEAR(NOW()),4,15),NOW()<=DATE(YEAR(NOW()),8,16)),$B$2:$B$5,$C$2:$C$5) - drag down

    you can use TODAY() instead of NOW()

    change system date to another year to see how it works

    see attached file:
    Attached Files Attached Files

  4. #4
    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: Formula to exclude year when using look up

    As falcondude has suggested, upload the workbook so that we can understand exactly waht you're getting at. Be sure to manually add the results you want and clearly identify them.

    However it would seem either build the year into the lookup table, i.e. extend the table, or leave the year out of the function value that's being looked up.
    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.

  5. #5
    Registered User
    Join Date
    10-19-2017
    Location
    Veteli, Finland
    MS-Off Ver
    2016
    Posts
    3

    Post Re: Formula to exclude year when using look up

    This is the basics of it. I've highlighted and commented on the problem area.
    Attached Files Attached Files

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Formula to exclude year when using look up

    You can change the formula in C15 to this:

    =IFERROR(IF(AND(DATE(2017,MONTH(B15),DAY(B15))>=Sheet2!$B$1,DATE(2017,MONTH(B15),DAY(B15))<=Sheet2!$C$1),VLOOKUP(A15,Sheet2!$A$2:$B$6,2),VLOOKUP(A15,Sheet2!$A$9:$B$13,2)),"")

    so that it converts the date in B15 to the reference year (2017).

    Hope this helps.

    Pete

  7. #7
    Registered User
    Join Date
    10-19-2017
    Location
    Veteli, Finland
    MS-Off Ver
    2016
    Posts
    3

    Re: Formula to exclude year when using look up

    Great! Thanks! It works :D

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Formula to exclude year when using look up

    You're welcome - thanks for the rep.

    If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post and mark this thread as SOLVED.

    Pete

+ 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. Count consecutive more than 3 days absent in a month/year exclude Sat/Sun/PubHol
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-30-2017, 12:51 PM
  2. [SOLVED] Calculate average and standard deviation for each year and exclude 0s
    By excelas88 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 05-01-2015, 05:37 PM
  3. Creating Year to Date formula using Vlookup or sumif and exclude #N/A
    By CassidiC12 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-24-2013, 07:27 PM
  4. [SOLVED] Keeping a date as current year, even though formula determines previous year
    By dropanddrive03 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-28-2013, 08:31 PM
  5. Replies: 0
    Last Post: 11-23-2012, 01:27 AM
  6. Replies: 0
    Last Post: 09-12-2009, 11:07 AM
  7. Replies: 3
    Last Post: 03-12-2009, 09:54 AM

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