Results 1 to 7 of 7

Thread: excel query....

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    excel query....

    hi,
    cud i make excel accept date of particluar format only?ecither manually or thru VB code......

    thanks and regards
    vivek.s

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: excel query....

    you format cells before you enter data into them, and it formats them as you enter the data. i don't think you can do anything other than check the data.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: excel query....

    yes.......i was able to format the cells to accept date of a particular format but if enter some text(grabage values) still it accepts it......is there anyway to restrict the column to only accept dates?

    thanks and regards
    vivek.s

  4. #4
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: excel query....

    Quote Originally Posted by vivek.shankar
    yes.......i was able to format the cells to accept date of a particular format but if enter some text(grabage values) still it accepts it......is there anyway to restrict the column to only accept dates?

    thanks and regards
    vivek.s

    As dglienna said,

    all you can do now is to validate the contents of the cell to see if it's a valid date from the garbage -

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: excel query....

    have the data entered into an unformatted cell. that way it will be easy to see what they were trying to do, rather than have excel change their input into what it thinks they wanted

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: excel query....

    Hey Vivek, you could use the selection and validate the cell contents there.
    If its not a date then clear the cell and alert the user.

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If IsDate(ActiveCell) = False Then
            MsgBox "Not a Date!", vbOKOnly
        End If
    End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Posts
    681

    Re: excel query....

    hi,
    how can i alert if its not of particular format?for example if it is not of mm-dd-yyyy format.......

    Thanks and Regards
    S.vivek

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width