+ Reply to Thread
Results 1 to 9 of 9

Modify code to erase data when another cell is cleared

  1. #1
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Modify code to erase data when another cell is cleared

    I am currently using the following code to add todays date into D when data is entered into G.

    Please Login or Register  to view this content.
    How can I modify it so that if the user erases the data in G then the date in D is also cleared?

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Modify code to erase data when another cell is cleared

    Would this work?

    Please Login or Register  to view this content.
    Last edited by berlan; 12-15-2013 at 05:03 PM.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,373

    Re: Modify code to erase data when another cell is cleared

    If you make a change to a cell within the Worksheet Change event handler, you should use
    Please Login or Register  to view this content.
    before, and
    Please Login or Register  to view this content.
    after the change.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Modify code to erase data when another cell is cleared

    Nice inputs TMShucks. With that in mind:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,373

    Re: Modify code to erase data when another cell is cleared

    @berlan: You're welcome.

  6. #6
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: Modify code to erase data when another cell is cleared

    Thank you for you responses. I tried that code, and while it will add the date when data is entered its not erasing it.
    I have attached my worksheet. The sheet in question is ReturnData. (hit Start Scan at the top to find the next empty row in G, and type in 58883)

    TMShucks out of interest why is the Application.EnableEvents code required? Ive been using that original code without any issues.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Modify code to erase data when another cell is cleared

    Sorry, I am afraid that I misunderstood you. I thought you also wanted to clear column G if you cleared the date.

    This may work:

    Please Login or Register  to view this content.
    By setting the Application.EnableEvents to false, it won't trigger any events that might occure by adding data to column D within the routine, in this case.

  8. #8
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: Modify code to erase data when another cell is cleared

    Perfect, that did it. Thank you.

  9. #9
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Modify code to erase data when another cell is cleared

    Anytime, Nitefox! Glad it worked

+ 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. VB Code to erase two cells as data changes in another
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 09-30-2013, 12:28 AM
  2. [SOLVED] once cell is cleared the totals result from code wont clear
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-19-2013, 02:33 PM
  3. VBA is inserting formula instead of cell data? Modify code, how?
    By ScubaGuy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2013, 10:55 AM
  4. [SOLVED] Macros code to erase data
    By Brainstorm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2012, 09:06 PM
  5. Code to erase certain data
    By daniels012 in forum Excel General
    Replies: 2
    Last Post: 01-11-2005, 05:34 PM

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