+ Reply to Thread
Results 1 to 3 of 3

replace cell content with username when modified

Hybrid View

  1. #1
    Registered User
    Join Date
    11-10-2008
    Location
    Akron OH
    Posts
    1

    replace cell content with username when modified

    I see some VB examples on how to put a time stamp with the users name into an adjacent cell when a cell is updated.
    Rather than putting it in the adjacent cell when a cell is updated, can the username replace whatever is entered into a particular cell? For example, if user keys anything in F5, the script would replace whatever the user keyed with their username.
    I see the adjacent cell examples here, but not quite what I'm looking for: http://www.excelforum.com/excel-misc...ime-stamp.html

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Hi Bobby, and welcome to the forum.

    The following code will replace anything any user types into cell F5 with their logged-in username.
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$F$5" Then Target.Value = Environ("Username")
    End Sub

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    You could use the following Worksheet Change event code

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
        If Not Intersect(Target, Range("F5")) Is Nothing Then
            Range("F5") = Application.UserName
        End If
    End Sub
    This assumes the users name is correctly logged in their copy of the Excel Application

    HTH

+ 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