+ Reply to Thread
Results 1 to 5 of 5

Username to autofill in when changing data on row

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-14-2010
    Location
    England
    MS-Off Ver
    2013
    Posts
    110

    Username to autofill in when changing data on row

    Hi,

    I would like it when entering information on a new row for it to automatically fill in the logged in windows username in a cell.

    I'd like it to also enter the windows username to a different cell when there is a change to an existing row.

    So essentially, each row would have 2 cells, 1 for the name of person who created the entry and the second one for the name of the person that last updated the row.

    Hope that makes sense.

    Cheers

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Username to autofill in when changing data on row

    Hi,

    This is the basic idea...
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Count > 1 Then Exit Sub
        If Not Target.Column = 1 Then Exit Sub
        If Target = "" Then Exit Sub
        If Target.Offset(0, 1) = "" Then
            Target.Offset(0, 1) = Environ("Username")
        Else
            Target.Offset(0, 2) = Environ("Username")
        End If
    End Sub
    It will place the username in column B for the first entry in column A and it will place the username in column C if the entry in column A is changed.
    Regards,
    Stephen

    If you feel someone has helped you please thank them and click on the star on their post to add reputation.
    Please ensure that you use code tags where relevant, and mark solved threads as solved.
    Most of all please be respectful and understanding of others.

  3. #3
    Forum Contributor
    Join Date
    01-14-2010
    Location
    England
    MS-Off Ver
    2013
    Posts
    110

    Re: Username to autofill in when changing data on row

    Hi,

    That works great thank you. Is it possible to update the username cells based on changes done anywhere on the row as apposed to column A?

    Cheers,

  4. #4
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Username to autofill in when changing data on row

    Yeah, if you can give me some more info or attach a sample sheet I may be able to help more.... otherwise you can do it like this:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Count > 1 Then Exit Sub
        If Range("B" & Target.Row) = "" Then
            Range("B" & Target.Row) = Environ("Username")
        Else
            Range("C" & Target.Row) = Environ("Username")
        End If
    End Sub

  5. #5
    Forum Contributor
    Join Date
    01-14-2010
    Location
    England
    MS-Off Ver
    2013
    Posts
    110

    Re: Username to autofill in when changing data on row

    Perfect, that works brilliantly!

    Thank you for your help

+ 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. VBA to save username when changing source cell value
    By swalesh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2016, 03:09 PM
  2. Changing location of audit trail depending on username.
    By Hannah Pattinson in forum Excel General
    Replies: 5
    Last Post: 05-16-2016, 08:15 AM
  3. [SOLVED] Changing UserName
    By NeedForExcel in forum Suggestions for Improvement
    Replies: 10
    Last Post: 03-25-2015, 01:01 AM
  4. Autofill not changing formula
    By floydian in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-01-2013, 11:43 PM
  5. [SOLVED] Username and Password Form - Show Username in Sheet
    By ryan180 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2013, 07:06 PM
  6. Macro for Autofill removes header info when there is no data to autofill
    By esturan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2012, 01:42 PM
  7. Autofill with changing data
    By Mags in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2005, 06:05 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