+ Reply to Thread
Results 1 to 10 of 10

Return date format in userform textbox

  1. #1
    Registered User
    Join Date
    08-22-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    55

    Return date format in userform textbox

    Good day everyone.

    What I'm trying to achieve is, the textbox should be able to return date value instead string from another sheet2.
    In sheet2 where the data is, I've set the respective cell as date.

    Once I run the userform, and click a partiular value from the listbox, I'm getting string "64322" instead of "1/1/2021"

    I've tried this, but no luck.

    Please Login or Register  to view this content.
    Last edited by kenjcd; 09-26-2021 at 06:47 AM.

  2. #2
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Return date format in userform textbox

    I'm confused. You talk about setting a cell's format to Date on Sheet2 but then say you are clicking a value from a ListBox on the UserForm. Where is the value in TextBox12 coming from... a cell or a ListBox item? It would be useful if you could upload a copy of your workbook (desensitize any sensitive information) so we could see your layout, your UserForm's construction and the code you are using to process the data. To attach a copy of your workbook, you must follow the instructions in the yellow banner at the top of this forum's webpage.

  3. #3
    Registered User
    Join Date
    08-22-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Return date format in userform textbox

    Hi Rick,

    Thank you so much for responding.
    In textbox12, I'm getting 44460 instead of a date(value from Sheet2, E1)
    Perhaps this workbook can help you better understand ya.
    Sorry for the confusion.
    Look forward to hear from you.
    Attached Files Attached Files

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Return date format in userform textbox

    in your listbox event.
    Please Login or Register  to view this content.
    in your Refresh Sub
    Please Login or Register  to view this content.
    you were trying to read a value that did not exist in your listbox because you had not covered the total range.

    You could save yourself 40 to 60 lines of code if you transferred data by looping through the textboxes to sheet cells
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  5. #5
    Registered User
    Join Date
    08-22-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Return date format in userform textbox

    Thank you so much torachan.
    I wish you well wherever you are!
    Rep added, and again, thank you!

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Return date format in userform textbox

    I have run through your code to demonstrate how little coding you need if using 'proper tables'.
    Also in your particular app there is no need for a search routine - there is a direct link between the listindex and the table row.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-22-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Return date format in userform textbox

    This is way much better! The one that I have is bit buggy.
    The direct link between the listindex and table row is VERY VERY helpful!
    Gadzillion thanks torachan!
    Last edited by AliGW; 09-25-2021 at 10:13 AM. Reason: PLEASE don't quote unnecessarily!

  8. #8
    Registered User
    Join Date
    08-22-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Return date format in userform textbox

    Quote Originally Posted by torachan View Post
    I have run through your code to demonstrate how little coding you need if using 'proper tables'.
    Also in your particular app there is no need for a search routine - there is a direct link between the listindex and the table row.
    Hi tora,

    How do I link myForm to userform1?
    Because I'm getting error, subcript out of range.
    I've changed the table reference from table1 to table13

    The commandbutton (Index) in myForm
    Please Login or Register  to view this content.
    Should be as simple as that right?
    Where am I doing wrong?
    Attached Files Attached Files

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Return date format in userform textbox

    your new 'Table13' is on Sheet4 not Sheet2

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-22-2010
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    55

    Re: Return date format in userform textbox

    PERFECT!
    Thank you.

+ 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] Date format for userform (textbox)
    By jp16 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-22-2018, 12:42 PM
  2. [SOLVED] Date Format in Userform Textbox
    By alteredbeast in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-10-2017, 03:58 AM
  3. [SOLVED] Date format in textbox userform
    By Crispy85 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2016, 06:57 AM
  4. [SOLVED] Excel 2010 - Userform - display date from textbox in a label or textbox in 'ddd' format
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2015, 10:54 PM
  5. [SOLVED] Userform Textbox Date Format
    By saban1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2014, 10:52 AM
  6. [SOLVED] Excel 2007, Userform Textbox Date Format and Calendar Control Userform
    By riffology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2014, 06:18 PM
  7. Date Format for textbox in userform
    By processchip in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2011, 06:42 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