+ Reply to Thread
Results 1 to 6 of 6

Extract Day, Month and Year from a text box (user input) date value

  1. #1
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Extract Day, Month and Year from a text box (user input) date value

    On my userform, I have a text box ("txt2") that asks the user to enter a date. I already have an IsDate sub running that ensures the input is in any date format, and then the excel column (H, column 8) the data is transferred to is formatted as date: mm/dd/yy - so all the dates entered should be formatted the same.

    What I want at the time of data transfer though is to extract (separately) the day, the month and the year from the date that the user input (it could be different than today's date). I'm thinking this might be easier to extract from the destination cell (as it is already formatted) but maybe not since that cell will be the next empty row every time the userform transmits the data??

    Here is my code:

    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Extract Day, Month and Year from a text box (user input) date value

    Please Login or Register  to view this content.
    is txt2.value actually in text format?
    format(txt2.value, "mm/dd/yy")
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Extract Day, Month and Year from a text box (user input) date value

    Try this:

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Extract Day, Month and Year from a text box (user input) date value

    Make and then use a real date:

    Please Login or Register  to view this content.
    Gary's Student

  5. #5
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: Extract Day, Month and Year from a text box (user input) date value

    I actually had what Humdingaling posted before I posted my question - but kept getting runtime 424 errors - which apparently I didn't have something exactly correct, 'cause humding's answer worked perfect on 2nd attempt.

    Alansidman code worked too, but needed a bit of tweaking as it returned a "/" in 2 of the fields.

    I haven't tried Jakobshavn's post yet - but it makes since to me and it appears it would work well too.

    Thanks to all!!!

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Extract Day, Month and Year from a text box (user input) date value

    Thanks for the feedback

+ 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. Replies: 3
    Last Post: 06-02-2014, 08:04 AM
  2. Macro or Formula to create Date range by getting input of month and year
    By indianhp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2013, 11:00 AM
  3. [SOLVED] Extract Year or Month only from a cell with date and time
    By djaurit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2013, 04:03 PM
  4. [SOLVED] Extract Text from String then Convert to a Date (Month/Year)
    By sgrey24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2013, 06:11 PM
  5. [SOLVED] Function to Display Input Box, Retrieve Date, and Return Day, Month And Year
    By Authentik8 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2012, 08:04 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