+ Reply to Thread
Results 1 to 8 of 8

I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015.

  1. #1
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015.

    Dear experts,
    Following code redirects user to enter date as intended format.
    I want to pop up a MsgBox if user enters date like 2015.04.30 instead of 30.04.2015.
    Any idea?
    Please Login or Register  to view this content.
    Thanks in advance.

    Useful link:
    https://msdn.microsoft.com/en-us/lib.../ff839468.aspx
    Last edited by HerryMarkowitz; 09-08-2015 at 06:20 AM.
    Sub DontForgetThese()
         If Your thread includes any code Then Please use code tags...
         If Your thread has been solved Then Please mark as solved...
         If Anybody has helped to you Then Please add reputation...
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015

    Please Login or Register  to view this content.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015

    Try:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  4. #4
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015

    Hi BellyGas,
    Thanks for answer. But your code doesnt work.

    Hi Kaper,
    I simplyfied your code below. Is there any mistake in following code?
    Please Login or Register  to view this content.
    In other words, I have deleted following lines in your code.
    Please Login or Register  to view this content.
    Last edited by HerryMarkowitz; 09-08-2015 at 09:59 AM.

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015

    The part you deleted was an attempt to make a valiw windows date out of sybmitted string.
    99.99.9999 seems to fit your "short version", but for sure it is not a valid date :-)

  6. #6
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015

    Hi Kaper,
    Run following code without changing pop up date then see there is an error on your code..
    Note: Be careful x and y declerations...
    Please Login or Register  to view this content.

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015

    As for declarations
    Please Login or Register  to view this content.
    is equivalent to
    Please Login or Register  to view this content.
    x is text or boolean (cancel clicked)
    y is a date if everytingg goes fine. if not OK, then y is not OK, set but err.number is <>0

    as for the code - there is an error in your code:-P you changed checking x with y in the long ElseIF
    compare posts #6 (your code) and #3 (my code)

    To drill it down a bit: what is your date format in system?
    try
    Please Login or Register  to view this content.
    to see it.

    if it is dd.mm.yyyy then even your code shall be fine. If not (in my case it is yyyy-mm-dd) of course not.
    That's why I checked x there - x is a string, as user writes in the inputbox.

    PS. note also my comment in post #5 why this checking is needed at all
    Last edited by Kaper; 09-09-2015 at 09:37 AM.

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

    Re: I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015

    Try
    Please Login or Register  to view this content.

+ 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. [SOLVED] need corrected data format of date & time like " 04-Jul-2015 23:52:41 020
    By arunjyoti.ec in forum Excel General
    Replies: 1
    Last Post: 07-26-2015, 03:42 AM
  2. [SOLVED] Change From 1 January 2015 Thursday to 1 January 2015 Thu
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2015, 11:47 AM
  3. Replies: 4
    Last Post: 07-06-2015, 08:39 AM
  4. New User 06/30/2015 -
    By ehdz0222 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 06-30-2015, 10:50 AM
  5. Want VBA Code to return funding depletion date in the Form 6/1/2015
    By Briandc72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2015, 12:56 PM
  6. [SOLVED] How many Mondays, Tuesdays, etc. in 2015 to date?
    By OverKnight in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-20-2015, 01:53 PM
  7. Replies: 6
    Last Post: 04-20-2015, 09:40 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