+ Reply to Thread
Results 1 to 7 of 7

Excel formula with date ranges

  1. #1
    Registered User
    Join Date
    05-19-2008
    Posts
    8

    Excel formula with date ranges

    Hi,

    Hopefully an easy one for you guys.

    I effectively want to write a formula in excel which does the following as I've written below:

    =IF([the date in this cell]=[any of the dates in this other range of cells],"X","")

    Hope that makes sense and someone can help me out.

    Thanks

    Dan

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    You use a countif statement like this:
    =IF(COUNTIF(B1:H500,A1),"X","")
    which says that if there is a count of at least one of the value found in A1 in the range then do the rest!
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    05-19-2008
    Posts
    8
    Thanks, that's great.

    Actually, I need an addition to it..

    If we have the same formula, but add to it:


    =IF(AND(COUNTIF(B1:H500,A1),"1"=[the variable in a new range in a different column but that which detects that it is in the same row as the date found in the first part of the formula])), "X","")

    I think that makes sense!.

    Help!

    Dan

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Nope! didn't make sense at all, why not post an example workbook so we can see what you are trying to achieve!

  5. #5
    Registered User
    Join Date
    05-19-2008
    Posts
    8
    Here is an example. I tried to attach an example sheet, but it didnt seem to work.

    Please Login or Register  to view this content.
    [/QUOTE]

    Anyway, say the cell with the Z is the one with the formula.

    Basically the formula should result in an X if:
    a) the date on the left of the cell (column A) is equal to any of the dates in the date list (column F) AND
    b) the room in the column of cell Z is equal to the room in Room List that is in the same row as the date that was derived in part A

    so, for instance, the cell would result in an X if, and only if there is a date in the Date list = 01/05/08 (TRUE) and the room adjacent to it in the room list is Room 1 (TRUE).

    if the applicable cell was cell Y, then the cell would result in an X if, and only if, there is a date in the date list = 03/05/08 (TRUE) and the room adjacent to it in the room list is Room 2 (FALSE as it is room 3). So in this case it would remain blank.

    So what would the formula be in excel for the applicable cell?

    Hope this is clearer now!

    Thanks

    Dan
    Last edited by Dan99; 05-19-2008 at 07:25 PM.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Hello Dan,

    Your example doesn't display very well. Does my attachment do what you want, formula in B2 copied across and down is

    =IF(SUMPRODUCT((datelist=$A2)*(roomlist= SUBSTITUTE(B$1,"Room","")+0)),"X","")
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-19-2008
    Posts
    8
    Yes, that actually works well. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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