Excel Auto insert username from Mr Excel


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Auto insert username
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

maxlm
Board Regular


Joined: 22 Jul 2003
Posts: 57
Location: San Francisco
Flag: Usa

Status: Offline

 Reply with quote  

Auto insert username

I need to be able to automatically insert user's username who made changes to the worksheet in a cell. Can you help how to do this.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim I As Range
Set I = Intersect(Range("C4:C500"), Target)

If I Is Nothing Then Exit Sub
Application.EnableEvents = False
Dim c As Range
For Each c In I
c.Offset(0, 1).Value = "trigger the username of person in code"
Next c
Application.EnableEvents = True

End Sub

Post Tue May 11, 2004 6:22 pm 
 View user's profile Send private message

OdinsDream
Board Master


Joined: 20 May 2002
Posts: 429

Flag: Blank

Status: Offline

 Reply with quote  

Re: Auto insert username

Would Track Changes be suitable for your situation? When a cell is changed, its original value is saved along with the username, and a timestamp. This is accessed by going to Tools > Track Changes > Highlight Changes.

Or you can access the username in your code with:

Application.UserName
_________________



Last edited by OdinsDream on Tue May 11, 2004 6:27 pm; edited 1 time in total

Post Tue May 11, 2004 6:26 pm 
 View user's profile Send private message Visit poster's website

pennysaver
Board Master


Joined: 15 May 2003
Posts: 2765
Location: San Diego, California
Flag: Usa

Status: Offline

 Reply with quote  

Re: Auto insert username

Here's how to capture the current user name:

Sub UserName()
    Dim CurrentUser As String
        CurrentUser = Environ("UserName")
        MsgBox CurrentUser
End Sub


Hope that helps,

Smitty

Post Tue May 11, 2004 6:27 pm 
 View user's profile Send private message Visit poster's website MSN Messenger

DRJ
Board Master
Board Master


Joined: 18 Feb 2002
Posts: 3193
Location: California
Flag: Usa

Status: Offline

 Reply with quote  

code:

c.Offset(0, 1).Value = Environ("USERNAME")



_________________






-Jacob

Post Tue May 11, 2004 6:30 pm 
 View user's profile Send private message Send e-mail

maxlm
Board Regular


Joined: 22 Jul 2003
Posts: 57
Location: San Francisco
Flag: Usa

Status: Offline

 Reply with quote  

quote:
Originally posted by DRJ:
code:

c.Offset(0, 1).Value = Environ("USERNAME")





Woooo... Thanks, this works perfect...

Post Tue May 11, 2004 6:47 pm 
 View user's profile Send private message

DRJ
Board Master
Board Master


Joined: 18 Feb 2002
Posts: 3193
Location: California
Flag: Usa

Status: Offline

 Reply with quote  

You're Welcome icon_beerchug.gif

Take Care
_________________







-Jacob

Post Tue May 11, 2004 7:11 pm 
 View user's profile Send private message Send e-mail

maxlm
Board Regular


Joined: 22 Jul 2003
Posts: 57
Location: San Francisco
Flag: Usa

Status: Offline

 Reply with quote  

Hi Jacob - thanks. I am not well on vba maybe you can help me with this one. Maybe using Case...? I Cant seem to get it done. Your help is really apprecicated. thanks.


I need to be able to put dates automatically on VBA for cells using offset shown below. The sample is only for one column. How do I get these cells to update for using following offsets.
Offsets:
j = 11
k = 1
l = 30
m = 4
n = 1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim I, j, k, l, m, n As Range
Set I = Intersect(Range("BC4:BC500"), Target)
Set j = Intersect(Range("AT4:AT500"), Target)
Set k = Intersect(Range("AD4:AD500"), Target)
Set l = Intersect(Range("AN4:AN500"), Target)
Set m = Intersect(Range("AL4:AL500"), Target)
Set n = Intersect(Range("AP4:AP500"), Target)

If I Is Nothing Then Exit Sub
Application.EnableEvents = False
Dim c As Range
For Each c In I
c.Offset(0, 1).Value = Format(Now, "mm/dd/yy")
Next c
Application.EnableEvents = True

End Sub

Post Tue May 11, 2004 11:16 pm 
 View user's profile Send private message

NateO
MrExcel MVP


Joined: 18 Feb 2002
Posts: 4658
Location: Minneapolis, Mn, USA
Flag: Canada

Status: Offline

 Reply with quote  

Re: Auto insert username

See your original thread regarding your latest request. icon_wink.gif

http://www.mrexcel.com/board2/viewtopic.php?t=88069
_________________
Regards,
Nate Oliver

Post Tue May 11, 2004 11:18 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.