+ Reply to Thread
Results 1 to 7 of 7

Add Date Stamp when cell if modified and delete if content is cleared

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    4

    Add Date Stamp when cell if modified and delete if content is cleared

    I need some help.

    I am trying to use an event Macro, so that if a cell is entered with "Y" a date stamp will appear to the left of the cell any where within the worksheet. I also need to be able to clear the date stamp if the contents of modified cell are cleared. Below is my unsuccessful attempt so far. Any ideas?
    Please Login or Register  to view this content.
    Thanks for any help!
    Last edited by Leith Ross; 07-31-2012 at 01:17 PM. Reason: Added Code Tags

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Add Date Stamp when cell if modified and delete if content is cleared

    nicholas.robinson,

    Welcome to the forum! In the future, please wrap your code in code tags. See forum rules (link in my sig) for how.
    As to your query, you need to tell the code what range of cells to monitor. Right now, the code is looking at every single cell in the worksheet to see if it is a "Y" or was deleted. Also, you have the macro calling itself recursively because you enabled events and then performed the ClearContents, which is considered a worksheet change, so code will keep calling itself until it errors because there is no column to the left of column A.

    So, basically, if you want to monitor column B from row 2 to row 500:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    07-31-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Add Date Stamp when cell if modified and delete if content is cleared

    I would actually like when certain columns are marked with "Y", i.e. if column F is marked with Y, a date stamp appears in column e; if column H is marked with Y, a date stamp appears in column g; etc. What would I need to change then.

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Add Date Stamp when cell if modified and delete if content is cleared

    Please Login or Register  to view this content.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Add Date Stamp when cell if modified and delete if content is cleared

    Hello nicholas.robinson,

    The only problem I see with your code is it is inserting the date and time. To insert only the time into the cell at the left, you can do it this way.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Add Date Stamp when cell if modified and delete if content is cleared

    Leith,

    Isn't that code missing an End If after the Application.EnableEvents = True?
    Also, doesn't my earlier point about the recursive calling still stand? I just tested the code and both problems arose immediately.

  7. #7
    Registered User
    Join Date
    07-31-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Add Date Stamp when cell if modified and delete if content is cleared

    Tigeravatar,

    Your code works wonders. Brilliant!! Thank you for the help!!! Saved me a lot of headaches.

    ~nicholas.robinson

+ 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