#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 516
Default User name

Is it possible to populate a cell automatically (with a formula) with the
name of the user that is in the windows user name?
Thanks?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default User name

I'm not sure if there is a direct (spreadsheet) way or not, but a simple UDF
can do it. Go into the VBA editor (Alt+F11), click Insert/Module from its
menu bar, copy/paste the following into the Module's code window that came
up...

Function UserName()
UserName = Environ$("USERNAME")
End Function

Rick


"Matt" wrote in message
...
Is it possible to populate a cell automatically (with a formula) with the
name of the user that is in the windows user name?
Thanks?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default User name

I probably should have mentioned how to use it (in case you are not familiar
with UDFs); after you have created the UDF, just enter this...

=UserName()

into your cell.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
I'm not sure if there is a direct (spreadsheet) way or not, but a simple
UDF can do it. Go into the VBA editor (Alt+F11), click Insert/Module from
its menu bar, copy/paste the following into the Module's code window that
came up...

Function UserName()
UserName = Environ$("USERNAME")
End Function

Rick


"Matt" wrote in message
...
Is it possible to populate a cell automatically (with a formula) with the
name of the user that is in the windows user name?
Thanks?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 516
Default User name

So...I performed the operation and it worked when I typed in the =Username()
and my login name came up...perfect. How will this work when I ask other
people to update templates with data. I have a template that asks for 2
pieces of data, column A and column K. A has a drop down from a list to
select a part number. From this, the particulars (name, cost, budget etc)
populates in Columns B:J. Then in column K is open for data entry...or what
we are asking for (current period activity). Then in column L, I want to
know who made the entry, hence the =UserName() . How do I get this function
to perform or update upon entry in cell A?

"Rick Rothstein (MVP - VB)" wrote:

I probably should have mentioned how to use it (in case you are not familiar
with UDFs); after you have created the UDF, just enter this...

=UserName()

into your cell.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
I'm not sure if there is a direct (spreadsheet) way or not, but a simple
UDF can do it. Go into the VBA editor (Alt+F11), click Insert/Module from
its menu bar, copy/paste the following into the Module's code window that
came up...

Function UserName()
UserName = Environ$("USERNAME")
End Function

Rick


"Matt" wrote in message
...
Is it possible to populate a cell automatically (with a formula) with the
name of the user that is in the windows user name?
Thanks?




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default User name

In that case use event code which will negate the need for Rick's UDF

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False
If Target.Address = "$A$1" And Target.Value < "" Then
Target.Offset(0, 11).Value = Environ("USERNAME")
End If
stoppit:
Application.EnableEvents = True
End Sub

This is sheet event code.

Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.

Alt + q to return to Excel

As written works only a value is selected fro A1 dropdown.


Gord Dibben MS Excel MVP

On Thu, 24 Jan 2008 11:45:03 -0800, Matt wrote:

So...I performed the operation and it worked when I typed in the =Username()
and my login name came up...perfect. How will this work when I ask other
people to update templates with data. I have a template that asks for 2
pieces of data, column A and column K. A has a drop down from a list to
select a part number. From this, the particulars (name, cost, budget etc)
populates in Columns B:J. Then in column K is open for data entry...or what
we are asking for (current period activity). Then in column L, I want to
know who made the entry, hence the =UserName() . How do I get this function
to perform or update upon entry in cell A?

"Rick Rothstein (MVP - VB)" wrote:

I probably should have mentioned how to use it (in case you are not familiar
with UDFs); after you have created the UDF, just enter this...

=UserName()

into your cell.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
I'm not sure if there is a direct (spreadsheet) way or not, but a simple
UDF can do it. Go into the VBA editor (Alt+F11), click Insert/Module from
its menu bar, copy/paste the following into the Module's code window that
came up...

Function UserName()
UserName = Environ$("USERNAME")
End Function

Rick


"Matt" wrote in message
...
Is it possible to populate a cell automatically (with a formula) with the
name of the user that is in the windows user name?
Thanks?






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 516
Default User name

Thanks Gord- I did this for the worksheet, however nohthing popluated in the
target field.
I chaged the worksheet a bit, Column A is still data entry (drop down list),
the persons name is to be populated in column C aka target cell. this is how
I changed the formula...what did I do wrong? Also the first cell to evaluate
will be cell a3.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False
If Target.Address = "$A$3" And Target.Value < "" Then
Target.Offset(0, 2).Value = Environ("USERNAME")
End If
stoppit:
Application.EnableEvents = True
End Sub




"Gord Dibben" wrote:

In that case use event code which will negate the need for Rick's UDF

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False
If Target.Address = "$A$1" And Target.Value < "" Then
Target.Offset(0, 11).Value = Environ("USERNAME")
End If
stoppit:
Application.EnableEvents = True
End Sub

This is sheet event code.

Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.

Alt + q to return to Excel

As written works only a value is selected fro A1 dropdown.


Gord Dibben MS Excel MVP

On Thu, 24 Jan 2008 11:45:03 -0800, Matt wrote:

So...I performed the operation and it worked when I typed in the =Username()
and my login name came up...perfect. How will this work when I ask other
people to update templates with data. I have a template that asks for 2
pieces of data, column A and column K. A has a drop down from a list to
select a part number. From this, the particulars (name, cost, budget etc)
populates in Columns B:J. Then in column K is open for data entry...or what
we are asking for (current period activity). Then in column L, I want to
know who made the entry, hence the =UserName() . How do I get this function
to perform or update upon entry in cell A?

"Rick Rothstein (MVP - VB)" wrote:

I probably should have mentioned how to use it (in case you are not familiar
with UDFs); after you have created the UDF, just enter this...

=UserName()

into your cell.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
I'm not sure if there is a direct (spreadsheet) way or not, but a simple
UDF can do it. Go into the VBA editor (Alt+F11), click Insert/Module from
its menu bar, copy/paste the following into the Module's code window that
came up...

Function UserName()
UserName = Environ$("USERNAME")
End Function

Rick


"Matt" wrote in message
...
Is it possible to populate a cell automatically (with a formula) with the
name of the user that is in the windows user name?
Thanks?





  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 516
Default User name

SWEET! Thanks!

"Matt" wrote:

Is it possible to populate a cell automatically (with a formula) with the
name of the user that is in the windows user name?
Thanks?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New user needs HELP marvin Excel Worksheet Functions 2 August 11th 06 04:29 PM
How do I format a cell, so the user must use a user calendar? nathan Excel Discussion (Misc queries) 1 January 16th 06 06:40 PM
How do I format a cell, so the user must use a user calendar? nathan Excel Discussion (Misc queries) 0 January 16th 06 05:26 PM
For a User Duncan Excel Discussion (Misc queries) 1 October 14th 05 01:24 PM
new user steve Excel Discussion (Misc queries) 2 July 11th 05 07:47 PM


All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"