Results 1 to 25 of 25

Check Date Format Input into Excel Column with VBA code ("DD/MM/YYYY" format)

Threaded View

inoka Check Date Format Input into... 12-11-2017, 04:11 AM
ranman256 Re: Check Date Format Input... 12-11-2017, 10:08 AM
inoka Re: Check Date Format Input... 12-11-2017, 11:40 PM
inoka Re: Check Date Format Input... 12-11-2017, 11:48 PM
inoka Re: Check Date Format Input... 12-12-2017, 01:31 AM
ikboy Re: Check Date Format Input... 12-12-2017, 04:11 AM
inoka Re: Check Date Format Input... 12-12-2017, 04:30 AM
jindon Re: Check Date Format Input... 12-12-2017, 06:31 AM
inoka Re: Check Date Format Input... 12-12-2017, 08:07 AM
jindon Re: Check Date Format Input... 12-12-2017, 08:14 AM
inoka Re: Check Date Format Input... 12-12-2017, 11:17 PM
jindon Re: Check Date Format Input... 12-12-2017, 11:20 PM
inoka Re: Check Date Format Input... 12-13-2017, 07:28 AM
inoka Re: Check Date Format Input... 12-13-2017, 07:43 AM
jindon Re: Check Date Format Input... 12-13-2017, 07:48 AM
inoka Re: Check Date Format Input... 12-14-2017, 12:42 AM
jindon Re: Check Date Format Input... 12-14-2017, 12:54 AM
inoka Re: Check Date Format Input... 12-14-2017, 02:54 AM
jindon Re: Check Date Format Input... 12-14-2017, 03:15 AM
inoka Re: Check Date Format Input... 12-14-2017, 04:20 AM
jindon Re: Check Date Format Input... 12-14-2017, 04:29 AM
inoka Re: Check Date Format Input... 12-14-2017, 07:42 AM
jindon Re: Check Date Format Input... 12-14-2017, 08:30 AM
jindon Re: Check Date Format Input... 12-14-2017, 07:58 AM
inoka Re: Check Date Format Input... 12-14-2017, 08:26 AM
  1. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Check Date Format Input into Excel Column with VBA code ("DD/MM/YYYY" format)

    Also, I need to validate it only 2 numbers for Date and 2 numbers for Month. and 4 numbers for Year. (DD/MM/YYYY)
    What's wrong with the current code?
    You are really confusing us, it only allows dd/mm/yyyy entry as you requested.

    If you are not able to adjust the code, you should ask everything in the first place.
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim rng As Range, r As Range
        Set rng = Intersect(Target, Range("M:M,T:U,Z:Z,AB:AD,AH:AI,CS:ST"), Rows("3:" & Rows.Count))
        If rng Is Nothing Then Exit Sub
        Application.EnableEvents = False
        With CreateObject("VBScript.RegExp")
            .Pattern = "^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/\d{4}$"
            For Each r In rng
                If Len(Target.Text) Then
                    If (.test(r.Text) * IsDate(r.Text)) = 0 Then
                        MsgBox "Invalid date", , r.Text & " " & r.Address(0, 0)
                        r.ClearContents
                    End If
                End If
            Next
        End With
        Application.EnableEvents = True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Check Date Format Input into Excel Column with VBA code
    By stanlelma in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 01-20-2024, 03:27 AM
  2. [SOLVED] Text box validation - date entry - format "dd mm yyyy"
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-25-2017, 09:01 AM
  3. [SOLVED] Userform Dynamically Generated Combobox format value as date ("mm/dd/yyyy")
    By CieloSalas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-12-2017, 03:39 PM
  4. Replies: 8
    Last Post: 06-21-2016, 08:56 AM
  5. Replies: 3
    Last Post: 08-13-2013, 06:25 AM
  6. [SOLVED] Format a column as date format "yyyy-mm-dd"
    By Seraph122 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-11-2013, 01:30 AM
  7. Replies: 1
    Last Post: 11-01-2012, 10:37 AM

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