+ Reply to Thread
Results 1 to 4 of 4

Validate YYYY/MM/DD with conditional formatting

  1. #1
    Registered User
    Join Date
    07-24-2019
    Location
    Durham, NC
    MS-Off Ver
    Office 365 (2016)
    Posts
    1

    Validate YYYY/MM/DD with conditional formatting

    Hello,
    I am trying to build a validation template that users will paste their data into. The idea is if they paste "2019/07/24" (YYYY/MM/DD), then the cell will do nothing. If they post any other date format, then it will highlight yellow. I am not trying to convert it to the correct format, just to display which ones are not correct. I would prefer a formula as opposed to VBA, if possible.

    As a last resort, I would even take a formula that would highlight if the cell does not begin with "2019/".

    Thanks!

  2. #2
    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: Validate YYYY/MM/DD with conditional formatting

    Welcome to the forum.

    If the cell being pasted into is pre-formatted using the date format you want, then any date which is a valid date should automatically display in that format. If it's not pre-formatted, then any valid date pasted in will take on the default short date format.
    A 'valid date' is anything which is valid according to your regional settings, which are probably set to the USA mm-dd-yyyy format. For example, any of these would be treated as valid:
    2019/07/24, 07/24/2019, 7-24-19, 07 24 19, etc.
    The only way I know of to get dates to not appear as dates is to pre-format the cell as text, which forces the pasted text to go in exactly as pasted.

    However, if you still need/want a Conditional Formatting formula, then try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    You should also use a second one to catch any non-valid date formats:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If there's a chance that pasted dates might have leading spaces, then amend the first formula to this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Hope that helps.


    Edit: as noted in the post below, this Conditional Formatting will only work if the users are pasting 'values' in, otherwise the formatting, including the CF, will be over-written. If that's going to be the case, then you'll need to highlight 'errors' in another cell which the users can't overwrite.
    Last edited by Aardigspook; 07-25-2019 at 10:43 AM.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Validate YYYY/MM/DD with conditional formatting

    Quote Originally Posted by dukefan3417 View Post
    Hello,
    I am trying to build a validation template that users will paste their data into. The idea is if they paste "2019/07/24" (YYYY/MM/DD), then the cell will do nothing. If they post any other date format, then it will highlight yellow. I am not trying to convert it to the correct format, just to display which ones are not correct. I would prefer a formula as opposed to VBA, if possible.

    As a last resort, I would even take a formula that would highlight if the cell does not begin with "2019/".

    Thanks!
    Highlighting like you want, requires Conditional Formatting (which you probably already knew)
    1. Copy/pasting into a cell with CF, removes the original formatting/CF, so, unless the source cell contains that CF rule, this is not going to work for you, the way you want it.
    2. A date in excel is just a number representing the number of days passed since 1/1/900...and then formatted in a way that we recognize as a date. So, for instance, today (Thu 25 Jul 2019) is actually 43671
    As long as the info being copied is a "real" date, the actual formatting wont matter to excel, as all it will rea;;y "see" is that 5-digit value
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Validate YYYY/MM/DD with conditional formatting

    Aardigspook thanks for the rep

+ 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. Replies: 2
    Last Post: 05-24-2016, 08:10 PM
  2. Data Validate by dd/mm/yyyy tt:tt (24 Hr)
    By ianflexie in forum Excel General
    Replies: 1
    Last Post: 05-20-2013, 11:24 AM
  3. Date Formatting - dd/mm/yyyy
    By IheartIUP in forum Excel General
    Replies: 1
    Last Post: 11-14-2012, 11:55 AM
  4. [SOLVED] Imported data contains strings dd.mm.yyyy how can I convert to date format dd/mm/yyyy inVB
    By Boormo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-05-2012, 05:48 PM
  5. Copy+Paste macro dd/mm/yyyy to dd/mm/yyyy and NOT dd/mm/yyyy to mm/dd/yyyy
    By uimhirADo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2012, 03:45 AM
  6. [SOLVED] Userform Date Formatting MM/DD/YYYY
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-09-2010, 12:51 AM
  7. [SOLVED] Validate mm/dd/yyyy
    By HotRod in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2005, 11:06 AM

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