+ Reply to Thread
Results 1 to 5 of 5

how to prevent debug error when I insert new rows with datetime & username stamp

  1. #1
    Registered User
    Join Date
    08-18-2015
    Location
    SG
    MS-Off Ver
    2007
    Posts
    4

    how to prevent debug error when I insert new rows with datetime & username stamp

    Hi,

    I'm using this codes for the date time stamp and updated by username for my excel. But I got a problem.

    (1) I got a row which is the header but I do not want the formula to run on this header if I made changes to it. How do I tweak my current codes?

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
    If Not Intersect(Target, Range("A:X")) Is Nothing Then
    Application.EnableEvents = False
    Intersect(Target.EntireRow, Columns("Y")) = Now()
    Intersect(Target.EntireRow, Columns("X")) = Environ("USERNAME")
    Application.EnableEvents = True
    End If
    End Sub

    (2) If I insert a row, the system will prompt debug. How do I overcome this?

    Your expertise in this is greatly appreciated.
    Thank you.
    Last edited by ladynana17; 08-31-2015 at 12:44 AM.

  2. #2
    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,447

    Re: how to prevent debug error when I insert new rows with datetime & username stamp

    Please use Code Tags for your code excerpts (to comply with forum rules)

    Whatever, try it this way:

    Please Login or Register  to view this content.

    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


  3. #3
    Registered User
    Join Date
    08-18-2015
    Location
    SG
    MS-Off Ver
    2007
    Posts
    4

    Re: how to prevent debug error when I insert new rows with datetime & username stamp

    Thank you for the prompt reply. It works. And thanks for telling me on code tags. Im a newbie.

  4. #4
    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,447

    Re: how to prevent debug error when I insert new rows with datetime & username stamp

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  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,447

    Re: how to prevent debug error when I insert new rows with datetime & username stamp

    For what it's worth, you could use:

    Please Login or Register  to view this content.

    Also note that you have an overlap between the range you monitor and the column you put the User Name.

    Regards, TMS

+ 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. Extracting Data from DateTime Stamp from Database
    By ashu611 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2015, 08:25 AM
  2. Username/Data/Time Stamp
    By KCKuhns92 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2014, 03:06 PM
  3. [SOLVED] Removing Seconds from Datetime stamp
    By mangesh in forum Excel General
    Replies: 2
    Last Post: 07-04-2014, 03:19 AM
  4. Count Occurrences of time stamp bewteen two times from DateTime Column
    By headric in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-18-2014, 09:08 AM
  5. Prevent Row Deletion, Allow Insert but Prevent Row Insert after certain #of rows
    By usumban in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 11:36 AM
  6. Stamp Username, Time & Date
    By djfatboyfats in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2007, 07:27 PM
  7. Username & Date/Time Stamp
    By Ken D in forum Excel General
    Replies: 4
    Last Post: 03-19-2006, 10:25 AM

Tags for this Thread

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