Results 1 to 25 of 25

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

Threaded View

  1. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

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

    So, you didn't know how to adjust...

    Change any cell(s) in Col.A, B
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim r As Range
        If Not Target.Column Like "[23]" Then Exit Sub
        If Target.Row < 3 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 Intersect(Target, Columns("b:c"))
                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