+ Reply to Thread
Results 1 to 6 of 6

February day 31

  1. #1
    Registered User
    Join Date
    05-25-2007
    Location
    Egypt
    MS-Off Ver
    2010
    Posts
    33

    February day 31

    Dear All,

    Attached is an Excel sheet that i designed it, But i have a problem with February it can't be 30 or 31 days. So i need an equation to solve this problem
    Attached Files Attached Files

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    February day 31

    Easiest would be to have a single validated date entry cell.

    However, using your posted workbook, perhaps Conditional Formatting?
    (see the attached workbook)

    Please Login or Register  to view this content.

    Now, whenever the 3 input cells have values, the CF will flag invalid dates.

    Is that something you can work with?
    Attached Files Attached Files
    Last edited by Ron Coderre; 12-06-2008 at 01:07 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    05-25-2007
    Location
    Egypt
    MS-Off Ver
    2010
    Posts
    33
    thanks man, But could you please explain the function u write thier and what is the meaning of ($b2 "_"

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    bruary day 31

    Your template uses 3 fields to build a date: B2, C2, and D2

    The conditional format formula checks that:
    • 3 values exist in those 3 cells
    • A valid date can be built using those 3 values

    It checks for a valid date by constructing "date text" from the cells
    and using that text string as the parameter of the DATEVALUE function:
    DATEVALUE($B2&"-"&$C2&"-"&$D2)

    Example:
    B2: 25
    C2: January
    D2: 1970

    Then:
    =DATEVALUE($B2&"-"&$C2&"-"&$D2)
    =DATEVALUE("25"&"-"&"January"&"-"&"1970")
    =DATEVALUE("25-January-1970")
    =25593 (The Excel date serial number for 25-January-1970)

    If the text cannot be a valid date (eg 31-February-1970), an error is returned.

    Note:
    The same exact formula must be applied to each cellin B2, C2, and D2.
    The dollar signs ($) in this formula DATEVALUE($B2&"-"&$C2&"-"&$D2)
    lock the column references as the formula is copied across.

    For more information, look up "range references" in Excel Help and check the sections on relative vs absolute references.

    I hope that helps.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    would be helpful if the sheets weren't hidden and password protected!
    but in your days validation list 1-31 replace
    29 with
    Please Login or Register  to view this content.
    it will evaluate year to see if its a leapyear and give 29 for february if it is
    ---------
    replace 30 with
    Please Login or Register  to view this content.
    and 31 with
    Please Login or Register  to view this content.
    then rearange sheet to make them put in year/ month/ day in that order then only the appropriate days will display
    Last edited by martindwilson; 12-07-2008 at 12:55 PM.

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Posting protected workbooks

    True, protected workbooks only make our job more difficult.

    Fortunately, in this case the one hidden sheet only holds the DV list sources

+ 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