+ Reply to Thread
Results 1 to 4 of 4

problem with an "if" statement

Hybrid View

  1. #1
    Registered User
    Join Date
    09-13-2015
    Location
    london
    MS-Off Ver
    2007
    Posts
    21

    problem with an "if" statement

    Hello guys, I am having trouble with this " if" statement and would like some advise.

    =IF((A31="Saturday,Sunday"),"",1234)

    Cell A31 is a day & date formatted cell like this Sunday, 13 Sep , 2015 . When the date occurs in A31 is Monday through Sunday the the statement results in false. I need to understand why the statement does not read the day part of the A31.

    I hope you can understand where I am coming from. Please raise and question with me if unclear.

    Thank you..

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,941

    Re: problem with an "if" statement

    =IF(OR(A31="Saturday,A31="Sunday"),"",1234)
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: problem with an "if" statement

    Hi, welcome to the forum.

    You need to understand something about how Excel deals with dates: all dates are stored as serial numbers, not as the dates themselves - so 13 Sep is '42260' (1 Jan 1900 is '1'). So it doesn't 'understand' that you're searching for Sat or Sun. Try this instead, which checks if the date is a Saturday (weekday 7) or Sunday (weekday 1):
    Formula: copy to clipboard
    =IF(OR(WEEKDAY(A31)=7,WEEKDAY(A31)=1),"",1234)

    That assumes your system settings have Sunday as the first day of the week - if you get incorrect answers, try 6 & 7 instead of 7 & 1.

    Hope that helps.

    Regards,
    Aardigspook

    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark Thread as Solved'.
    You don't need to give me rep if I helped, but thanks are appreciated.

  4. #4
    Registered User
    Join Date
    09-13-2015
    Location
    london
    MS-Off Ver
    2007
    Posts
    21

    Re: problem with an "if" statement

    Thank you Aardigspooks this works perfectly. Now that the front end of my formula works I can carry on trying to create the backend.
    Many thanks you are a diamond...

+ 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 Evaluates as "TRUE" but Returns "FALSE" Value (Excel 2007)
    By Simcik in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-11-2014, 12:43 PM
  2. Replies: 12
    Last Post: 06-12-2014, 02:11 PM
  3. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  4. Problem Checking Range.Name Through "IF" Statement
    By neese016 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2011, 09:42 PM
  5. Problem using "Cells" in "Range" "400" error
    By johnnywinter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2009, 05:46 PM
  6. Replies: 4
    Last Post: 09-17-2008, 08:00 PM
  7. Replies: 3
    Last Post: 12-14-2006, 01:36 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