+ Reply to Thread
Results 1 to 33 of 33

how to restrict the date format and assign the autonumber automatically for each column?

  1. #1
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    how to restrict the date format and assign the autonumber automatically for each column?

    how to restrict the date format (e.g dd/mm/yyyy) and assign the autonumber automatically for each column?

    Thank for helping!!

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Please Login or Register  to view this content.
    I'm not sure how to autonumber a column based on what you've said .. Can you be more explicit
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    why I still cannot restrict the date format
    My code is
    Private Sub textbox_date_change() <--- I wanna input the data in textbox_date
    Range("S:S").NumberFormat = "ddd dd mmm yyyy"
    End Sub

    The Range("S:S") mean that I would like to input the data in S6,S7,S8,S9,etc.... am I right??

    I want to automatically assign the item number to each data I have input.
    Sorry for my unclear interpretation.

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    OK .. now you mention textboxes and incremental row storage, I have a clearer idea

    Give me a while and I'll get back to you with a proposed solution.

    Please Login or Register  to view this content.
    Last edited by AndyLitch; 06-30-2013 at 06:29 AM.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    please add code-tags if you show procedures here in the forum.

    I would not recommend to use the change-event but rather the exit-event, and I would restrict the texbox to just accept numbers and one kind of limiter/divider in order to evaluate the date.

    The Range("S:S") mean that I would like to input the data in S6,S7,S8,S9,etc.... am I right??
    Not really - it will give the number format to the whole column. From what I read you would rather need something like
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  6. #6
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Re andy,

    whether I use Private Sub CommandButton1_Click() or Private Sub textbox_date_change(),
    I can still input the wrong date type (e.g. I have successfully typed 2323232 and the system did not restrict it)

  7. #7
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Re HaHoBe,

    Do you means the code should be
    Private Sub textbox_date_change()
    Range("S") & Rows.Count.End(xlUp).Offset(1, 0) = Format(textbox_date_change.Value, "ddd dd mmm yyyy")
    End Sub

    If it is correct, the code is still cannot work = =

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    maybe I should have a better look at what I type - it should read
    Please Login or Register  to view this content.
    Maybe you should indicate how your value inside the textbox will look like.

    Please remember to add code-tags around your procedures posted here.

    Ciao,
    Holger

  9. #9
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Please Login or Register  to view this content.
    I have typed these code in my textbox, but it still cannot restrict the date type of the input data.
    When I type "32323232", it displays a lot of date with "ddd dd mmm yyyy" format.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    what would you like to type into the texbox and a) how should that look in the textbox and b) how should it look like in the worksheet? I mentioned before that I would not use the change-event as that gets triggered by any change/entry inside the Textbox (which I doubt might be useful as the change of date format should trigger that event as well).

    How about using a userform for choosing the date instead of typing the information into a textbox?

    Ciao,
    Holger

  11. #11
    Forum Contributor
    Join Date
    08-22-2012
    Location
    nj, us
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Jason your original question appears to be evolving

    Quote Originally Posted by jasonlewis View Post
    how to restrict the date format (e.g dd/mm/yyyy) and assign the autonumber automatically for each column?

    Thank for helping!!

  13. #13
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Re HaHoBe,

    Here is my sample, maybe it can help you understand easily.
    Do you mean using a combo box to replace text box?
    Attached Images Attached Images
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    re john, the code is not work.

  15. #15
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Re Andy,

    maybe...

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    it would have been nice if the workbook had shown a couple of sample data how it should look like as well as the UF oyu have developed, and although I tried very hard I canīt get the *.png into my VBE for testing. Besides: I wanted to know if you enter for example
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    into the textbox (or how you want the date entered to look like while entering and for putting into the workbook).

    And as a note: I donīt like MergedCells. I can work wioth them but I like it better to simply avoid them.

    Ciao,
    Holger

  17. #17
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Maybe I update my work here, so that u may know my condition clearly.

    the data is just a sample format.
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    08-22-2012
    Location
    nj, us
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    For cdate(date) date is the wanted date



    Also, it is columns(s:s) not range

  19. #19
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Are you giving a suggestion for my code regarding how to restrict the date format?

  20. #20
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Anyone knows how to do it ><

  21. #21
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Do someone know how to assign the autonumber automatically for each column?

  22. #22
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    in Post#3 you add code showing a textbox but I canīt find one in any of the workbooks you uploaded. You show a picture of how that form may look like - but having the picture is one thing and seeing this UserForm/form in Excel/VBA is something else because that might show the necessary information to answer your questions.

    Ciao,
    Holger

  23. #23
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Here is my sample form,
    I want the system automatically assign the item no. when I enter any item code each time.

    Also I wanna know how to set the value of monthview control to today date. Thanks.

    PW:vbapass
    Attached Files Attached Files
    Last edited by jasonlewis; 07-09-2013 at 09:57 PM.

  24. #24
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    Here is my sample form,
    Maybe but somebody has locked the VBA-Project so I at least canīt tell if itīs in there. I get the note that one control (MonthView) isnīt installed on my PC but I canīt help to overcome it. So what I shall I answer on a workbook with a protected sheet with a protected VBA-Project?

    Iīve got one on my mind: I wonīt let you have part of my protected knowledge.

    Holger

  25. #25
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Sorry, I forget to give my pw to u all,
    My pw:vbapass


    And I can successfully assign the autonumber for each column automatically.
    However, I dun know how to set the value of the monthview control to today date
    And my fd said that did not know the reason why he enter the date (10/7/2013) into the form, it output to 7/10/2013.

    Moreover, he have set the other two reasons (broken and contaminated) to restrict any input into the monthview control box, but he dun know why it still can output the date of expiration.

    Thanks.

  26. #26
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    code is untested:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Ciao,
    Holger

  27. #27
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Thanks.

    But can I set the grey oval shape cover the today date only? I dun want to compel the users must select the today date. (JUST LIKE the pics I uploaded)

    Also, I dun know why I also have the problem that when I enter the date (11/7/2013) into the form, it output to 7/11/2013.

    Moreover, I hv set the other two reasons (broken and contaminated) to restrict any input into the monthview control box, but it still can output the date of expiration.

    Thanks,Jason.

    123.PNG

  28. #28
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    I have solved the problem of 2 and 3,

    But do someone know how to set the grey oval shape cover the today date only? I dun want to compel the users must select the today date. (JUST LIKE the pics I uploaded)

    Thanks,Jason.

  29. #29
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Hi, jasonlewis,

    I have solved the problem of 2 and 3
    What about posting the solution you used for other users as a reference?

    But do someone know how to set the grey oval shape cover the today date only?
    When I ran the control with my code todayīs date was circled in red - I doubt anything else will be available from the control. And thatīs the caveat of the control as you will not see which date was selected (you would need to push that date into a label or textbox or variable to further work with it and know what has been chosen - if I understand the control correctly).

    Ciao,
    Holger

  30. #30
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    as for the problem2, I use monthview_control to enter the date.
    as for the problem3, I use if to make condition.

    And I want to explain more about what I am doing,
    For instances, when the user enter the data in 11/7, I wanna the grey oval shape to cover 11/7, so they dun need to select today date again and again. And when the user enter the data in 15/7, I wanna the grey oval shape to cover 15/7.
    Attached Images Attached Images

  31. #31
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Now, I realise a new problem of "how to restrict the date format",
    I dun know why I enter the date in the monthview_control, it output to text format, not the date format..
    Thus, how can I restrict the date format?

  32. #32
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Does someone know how to solve this problem?

  33. #33
    Registered User
    Join Date
    06-29-2013
    Location
    Hong Kong
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: how to restrict the date format and assign the autonumber automatically for each colum

    Does someone know how to solve this problem?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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