+ Reply to Thread
Results 1 to 4 of 4

Fix change event code to add todays date when data is added to multiple cells in column

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

    Fix change event code to add todays date when data is added to multiple cells in column

    I have some Change event code which among other things adds todays date into D when data is first entered into G.
    The issue I'm having is when I paste data into more than one G cell at the same time it doesn't work. How can I fix this?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: Fix change event code to add todays date when data is added to multiple cells in colum

    Here:
    Please Login or Register  to view this content.
    you force the procedure to quit if there is more than 1 changed cell. change it to:
    Please Login or Register  to view this content.
    few lines later it is again (useless, because if the condition were met it would never be executed) so delete:

    Please Login or Register  to view this content.
    and ... I am reading with further on several times checking again.

    Ok. I'll try to suggest complete final version (no attachment, so not tested)



    Please Login or Register  to view this content.
    I wrote it without testing, so check syntax, etc.

    Summarizing: As I said - remove all checkin of target.cells.count
    In all cases where action on target shall be made cell by cell just do it - for each cell in target (or subset of target) do something.

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

    Re: Fix change event code to add todays date when data is added to multiple cells in colum

    Thank you Kaper that fixed it.
    Im not very experienced when it comes to VB, is there something further that your recommending I do to fix up the code?

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: Fix change event code to add todays date when data is added to multiple cells in colum

    Hi,
    I am glad it hepled.
    I do not really see the point to react on any changes out of column G (the three special cases are all about some change in column G). So may be you could narrow the field here:
    Please Login or Register  to view this content.
    for instance to
    Please Login or Register  to view this content.
    Once you do it (or even if not) here
    Please Login or Register  to view this content.
    you start from G2. If the changed range is simply G2 this part will never be executed, because of the first checking whether target intersects with G6:G_last_

    So it is probably right to write:
    Please Login or Register  to view this content.
    if you do not expect that
    Please Login or Register  to view this content.
    is different (lower row number) than
    Please Login or Register  to view this content.
    which is checked just at the beginning you could change also this part.

+ 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. Replies: 3
    Last Post: 12-10-2012, 06:57 AM
  2. Replies: 5
    Last Post: 09-23-2012, 08:51 AM
  3. VBA Code: Change event, multiple if's for a range
    By dhopman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-13-2012, 11:27 AM
  4. Change event - Inputing date into specific column
    By everettjsj2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2010, 12:36 PM
  5. [SOLVED] change event for multiple cells
    By Guy Normandeau in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2006, 04:20 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