+ Reply to Thread
Results 1 to 4 of 4

Trouble with a date and username stamp macro

  1. #1
    Registered User
    Join Date
    07-09-2014
    Location
    Naperville, IL
    MS-Off Ver
    office 2013
    Posts
    29

    Trouble with a date and username stamp macro

    Hello,

    I am looking to create a macro which takes any input in columns A through D and stamps a username and a date in columns 7 and 8 respectively. Here is the code I currently have, and I can't figure out why it isn't working. Any assistance would be greatly appreciated.

    Marc

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim rCell As Range
    Dim rChange As Range

    On Error GoTo ErrHandler
    Set rChange = Intersect(Target, Range("A:D"))
    If Not rChange Is Nothing Then
    Application.EnableEvents = False
    For Each rCell In rChange
    If rCell > "" Then
    Cells(Target.Row, 7).Value = UserName()
    Cells(Target.Row, 8).Value = Date & " " & Time()

    Else
    rCell.Offset(0, 1).Clear
    End If
    Next
    End If

    ExitHandler:
    Set rCell = Nothing
    Set rChange = Nothing
    Application.EnableEvents = True
    Exit Sub
    ErrHandler:
    MsgBox Err.Description
    Resume ExitHandler
    End Sub

    Public Function UserName()
    UserName = Environ$("UserName")
    End Function
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Trouble with a date and username stamp macro

    Your sheet works for me

    (a tiny change but nothing related to your problem would be to amend the following line:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Trouble with a date and username stamp macro

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-09-2014
    Location
    Naperville, IL
    MS-Off Ver
    office 2013
    Posts
    29

    Re: Trouble with a date and username stamp macro

    Thanks for the help guys. After restarting my computer, it works. I find that sometimes after I close and reopen the workbook, the change event macro stops working. Is there something with my settings that I need to fix?

+ 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. Posting time stamp and username using command button
    By mcav16 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2014, 04:08 PM
  2. Static Date Stamp without using a macro?
    By ride_op in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 03-30-2011, 08:46 PM
  3. Trouble with Date Stamp
    By ex400lc-3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2008, 06:34 PM
  4. Stamp Username, Time & Date
    By djfatboyfats in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2007, 07:27 PM
  5. Username & Date/Time Stamp
    By Ken D in forum Excel General
    Replies: 4
    Last Post: 03-19-2006, 10:25 AM

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