+ Reply to Thread
Results 1 to 13 of 13

Correctly formatting a date inserted from an input box

  1. #1
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Question Correctly formatting a date inserted from an input box

    Hello everyone. I need your help.

    In fact I using this code (Thanks to walruseggman)

    Please Login or Register  to view this content.
    It works great but when the input box pops up to force a date in column B and because I live in Europe I enter the date dd/mm/yyyy and when I click ok it appears as mm/dd/yyyy in the cell. The cell is correctly formated. Is there a way to solve this?

    For more information see this thread http://www.excelforum.com/excel-prog...two-dates.html

    Thanks for your help

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Correctly formatting a date inserted from an input box

    You could try using CDate or DateValue to convert the text date from the input box to a 'real' date.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    Quote Originally Posted by Norie View Post
    You could try using CDate or DateValue to convert the text date from the input box to a 'real' date.
    Please Login or Register  to view this content.
    Wow what a quick reply. Thanks.
    Yes it takes it as a real date now, but, the date is accepted even if the time limit of 6 weeks is exceeded.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Correctly formatting a date inserted from an input box

    In this part of the code you don't check what's been input via the input box.
    Please Login or Register  to view this content.
    You probably want to repeat the check you have in the first If statement, and you might even want to check if a valid date has been entered.

    Something like this perhaps, though I'm not sure if I've got the columns right.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    Thanks norie.
    The problem now is that it return always the message even if the entered date is less than 6 weeks. Please don't forget that we enter the date always dd/mm/yyyy.
    Last edited by dekueb; 01-20-2016 at 07:11 AM.

  6. #6
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    Can someone help me with this?
    Thx in adv.

  7. #7
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    Ok seems to work now with this code don't know why but anyhow....but one fixed an other appear. When I click *cancel in the input box I recieve a error message. So whats the if statement?
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    Can someone help me please

  9. #9
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    No chance to get help?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Correctly formatting a date inserted from an input box

    You shouldn't put the result from the input box directly into the cell, or directly into the CDate function.

    Instead put it in a variant variable, as I did in the code I posted, then it can be checked to see if a valid date has been entered and/or Cancel has been pressed.

  11. #11
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    Thanks norie.
    But the problem is, when useing your code, that it return always the message *Can not exceed 6 weeks* even if the entered date is less than 6 weeks as I already mentionned in post #5. Because no one respond to that post (don't see this as a complaint. I know we have all our private life) I tried to solve it by my one.

    So thanks for any help.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Correctly formatting a date inserted from an input box

    Perhaps this will work.
    Please Login or Register  to view this content.
    If that doesn't work can you explain in words exactly what the code is supposed to do.
    Last edited by Norie; 01-25-2016 at 03:14 AM.

  13. #13
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: Correctly formatting a date inserted from an input box

    Thanks norie.
    It works now.

+ 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. Date Not Formatting Correctly
    By sam8114 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2013, 02:09 PM
  2. [SOLVED] Formatting a date from a VBA input box
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2013, 11:14 AM
  3. Replies: 2
    Last Post: 04-26-2012, 02:47 PM
  4. Search and create a register with values inserted into user input form
    By confused.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2010, 08:24 AM
  5. Formatting date input order?
    By boostjunkie in forum Excel General
    Replies: 1
    Last Post: 02-09-2010, 05:19 AM
  6. How to position a button correctly when a new row is inserted
    By Aswathy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-24-2008, 03:43 AM
  7. Replies: 3
    Last Post: 03-25-2006, 12:25 PM
  8. [SOLVED] Conditional formatting - different cell colour for each year following from user input date?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 01-11-2006, 03:15 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