+ Reply to Thread
Results 1 to 11 of 11

Code required to accept today date.

  1. #1
    Registered User
    Join Date
    08-18-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Exclamation Code required to accept today date.

    Hi Folks,

    I am new to VBA programming and i required one code which will allow me to update only todays date in particular cell in that cooumn and once the date has been entered it will save as value so that next day it will not change the date.

    Aprreciate your help.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Code required to accept today date.

    One way...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-18-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Code required to accept today date.

    Thanks for quick reply donkeyote,

    However i want this code to run at back end and when any user try to enter previous date in particular cell lets say "E345" then it should not allow him to do so.

    Actually this is to track the daily activity and to maintain data integrity.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Code required to accept today date.

    Have you thought of perhaps using Data Validation? http://www.contextures.com/xlDataVal06.html

    I'm not really sure I understand the workflow you are trying to implement in this instance...

  5. #5
    Registered User
    Join Date
    08-18-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Code required to accept today date.

    Dude thanks for reply.

    If the user copy the previous date then the validation will remove from tht cell and it will accept. however if user will type the date then will not be able to do tht validation will show an error to user.

    So please guide me if there is any other alternative

  6. #6
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Code required to accept today date.

    Please try
    Please Login or Register  to view this content.
    1st part will put the current date into cell A1.
    2nd part will, when a user trys to select the cell A1 it will select the cell to the right.
    Note this is not 100% fool proof though may do the trick.
    Adjust the ranges to suit.

  7. #7
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Code required to accept today date.

    Reread your question.
    DonkeyOte's code for the 1st part is what you want,
    The code i provided will update the date each time the sheet is activated.

  8. #8
    Registered User
    Join Date
    08-18-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Code required to accept today date.

    hi D_Rennie

    Actually the way i want the data i like
    A B C D E
    1 sachin EX DB 21/8/2009

    There are 5 colums and in 5th i.e "E" coloums user has to enter the current date. sometimes he forgot to put the data in sheet then he will come next day and put the previous date. that is wht i want to restrict the user to use previous date. so that user can fill the daily actvity sheet regularly and on time. this may help me to do right analysis wht my user is doing.

    I guess u got it wht i want to convey. so please help me user are furging the data and i cant track tht.

  9. #9
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Code required to accept today date.

    you lost me completly in the last post.

    IF you have someone that forgets to do his job on time, though comes in the next day and backdates it. WHY do you want to restrict it to only allow todays date. If they are forgetfull the system will fail.

    Or are what you saying you want to restrict him/her from only being able to use todays date or yesterdays date. so then you can see if they are 2+ days behind.
    If this is the case you are probely better off using data validation on each cell in that row.

  10. #10
    Registered User
    Join Date
    08-18-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Code required to accept today date.

    Hi, D_Rennie

    I can use data validation for date however when i copy paste the previous date then it will accept the change.

    SO PLEASE GUIDE ME.

  11. #11
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Code required to accept today date.

    Ok i see where you are comming from now.

    Try
    Put this in the worksheet code section.
    Please Login or Register  to view this content.
    Change the range to suit.

    Hope that helps

+ 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