+ Reply to Thread
Results 1 to 6 of 6

if statement based on cell range

  1. #1
    Forum Contributor
    Join Date
    02-27-2015
    Location
    Los Angeles, California
    MS-Off Ver
    office 2010 pro
    Posts
    238

    if statement based on cell range

    hello everyone, my name is rachel and i have a question that is hard for me to explain. I've uploaded the workbook for an easier understanding.

    This is a trip itinerary and the area of the workbook in question is the F column, specially highlighted in yellow.

    Column B is determining whether or not a hotel stay is needed.

    Column C is my choice of how long a stay will take place based on whether or not the corresponding cell in B is a "y" value.

    Column E is the original departure date or the beginning of this trip.

    Column F is the arrival date. Cell F6 is based on Cell E3 & the first time a "y" is present in the corresponding B cell.

    Column G is just a duplicate of Column C and may be eliminated in the future.

    Column H is simply the Arrival Date Cell + Stay duration (as of now it is the corresponding G cell, but may be switched the corresponding C cell)+1.

    What I'm looking for is the next time "y" is present in column B the corresponding F cell needs to display the previous H cell. In my workbook, cell F9 = H6. Cell F10=H9, etc etc.

    *I'd also like the cells in the F column to remain blank until a "y" is present in the corresponding B cell.

    I hope that makes sense and i hope that it's possible. Any help in this matter would be greatly appreciated. Thank you in advance to anyone who takes time from their day to assist me!!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,958

    Re: if statement based on cell range

    Try this in F7:

    =IF(C7="","",LOOKUP(10^10,$H$3:H6))

    Copy down.

  3. #3
    Forum Contributor
    Join Date
    02-27-2015
    Location
    Los Angeles, California
    MS-Off Ver
    office 2010 pro
    Posts
    238

    Re: if statement based on cell range

    yes it works, thank you. Could you take a moment and explain to me what the "lookup" function is actually saying?

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,408

    Re: if statement based on cell range

    In F7

    LOOKUP(10^10,$H$3:H6))

    LOOKUP finds the value in H3:H6 which less than or equal to 10^10: 10^10 is just a very large number so we will always find a number (date as Excel dates are just numbers) less 10^10 AND it will be the last in the range we are looking at.

    In F9 (first non-blank cell) it is the date in H6.

    in F10 it is F9 .. and so on.

    NOTE: for LOOKUP to work, values have to be in ascending sequence (as your dates are)

  5. #5
    Forum Contributor
    Join Date
    02-27-2015
    Location
    Los Angeles, California
    MS-Off Ver
    office 2010 pro
    Posts
    238

    Re: if statement based on cell range

    thank you very much for explaining it, i understand now!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,698

    Re: if statement based on cell range

    Hi, Rachel!

    LOOKUP(10^10,$H$3:H6)

    is tricking Excel into returning the bottom most date in the range $H$3:H6. H6 will increment as you drag copy down, expanding that range one row at a time. 10^10 (ten to the power of ten) is a higher number than will ever be found in the date column (remember that Excel sees dates as serial numbers, so 09/03/2017 is actually 42803), and because it can't find it, it returns the nearest number it can find, which is the latest date in that range.

    You can do a similar thing with text entries like this:

    LOOKUP("zzzzzzzzz",$H$3:H6)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. [SOLVED] IF Statement needed to change cell value based on input of another cell
    By kschmit1 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-20-2016, 11:41 AM
  2. [SOLVED] IF statement to return string based on highest value in range of columns
    By SeskaLien in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-15-2015, 10:10 PM
  3. Highlighting range of cells based on an array if-statement (not using loops)
    By clabulis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-22-2014, 02:23 PM
  4. Replies: 2
    Last Post: 07-27-2014, 11:48 PM
  5. How to run an IFerror statement based off a certain date range?
    By BrianKelleher in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2014, 01:54 PM
  6. [SOLVED] Need IF statement (inside of Linest Function) that will select range based on dates
    By cpkrehbiel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-07-2014, 09:22 PM
  7. If statement based on cell data, if falls in range.
    By finch82 in forum Excel General
    Replies: 3
    Last Post: 10-27-2011, 04:11 PM

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