[SOLVED] using USER NAME in a cell

weefisheads

Active Member
Joined
Mar 18, 2006
Messages
351
There are 4 folks in my office that use the same file to enter data and it would be really neat to know who's entering what. I know the "track changes" options can be used to do this, but I was hoping there's a private sub or something so that when an event happens - change to a certain cell - the USER NAME of the person will appear in, say, a1.

Possible?

Thanks,

dB
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
weefisheads

I am sure this can be done but I am wondering how it would be of use. For example if Fred changes a cell, his name would appear in A1 but if Jill then immediately changed a cell Fred's name would be gone and Jill's would be in A1. Or is it just the person who made the last change what you want?

Edit: Also, is it a particular cell change that is to trigger this or a change to any cell?
 
Upvote 0
Oh, I was just using A1 as an example. In reality it would be a change in a column, but if I can understand how to get a USER NAME to appear in A1 then methinks I can taylor it to what I want.

And I figure I'd tie it to the event of changing a specific cell.

Thanks for your help...

dB
 
Upvote 0
Hello weefisheads,
An example that will list the username(s) down column A whenever a change is made in cell D2. (Code goes in the sheet code module for the sheet of choice.)
Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("D2")) Is Nothing Then
    If [A1] = "" Then
        [A1].Value = Environ("UserName")
    Else
        Cells(Rows.Count, "A").End(xlUp)(2, 1).Value = Environ("UserName")
    End If
End If
End Sub

Hope it helps.
 
Upvote 0
Hi
set the sheet and name it "Secret" then
try
paste the code onto ThisWorkbook module
Code:
Private oldData

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim i As Long, ii As Long
If Sh.Name = "secret" Then Exit Sub
Application.EnableEvents = False
If Not IsArray(oldData) Then
    If oldData <> Target.Value Then
        Sheets("secret").Cells(Rows.Count, "a").End(xlUp).Offset(1) = _
        Application.UserName
    End If
Else
    For i = 1 To UBound(oldData, 1)
        For ii = 1 To UBound(oldData, 2)
            If Target.Cells(i, ii) <> oldData(i, ii) Then
                Sheets("secret").Cells(Rows.Count, "a").End(xlUp).Offset(1) = _
                Application.UserName
                Exit For
            End If
        Next
    Next
End If
Application.EnableEvents = True
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
oldData = Target.Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,026
Members
449,061
Latest member
TheRealJoaquin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top