Solved

Formual to bring windows username (excel 2003)

Posted on 2011-03-20
13
205 Views
Last Modified: 2012-05-11
.. just like when one tracks the changes it displays the name of the user.

but I would like to display it via a formula.

Thanks,
JP
0
Comment
Question by:easycapital
  • 7
  • 6
13 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35176911
You can use a UDF by the function

=usrname()

and the code behind the function is

Function usrname()
usrname = Environ("username")
End Function

Saqib
0
 

Author Comment

by:easycapital
ID: 35176925
Should I type some additional code such as Sub...

Thanks,
JP
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35176931
No Just paste the function...end function in a module

and enter the formula =usrname in the worksheet
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35176935
sorry, usrname()
0
 

Author Comment

by:easycapital
ID: 35176945
I have attached excel workbook. Could you please take a look at it.  I added VBA on sheet 1.  I will be exporting the sheet, so I think the VBA should be there.

Thanks,
JP
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35176961
Still waiting for the file.

Meanwhile,

- Go to the VBA window
- go to     Insert > Module
- Paste the given code there
- Go to the worksheet
- Paste or type the function

=usrname()

Saqib
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:easycapital
ID: 35176976
Hi Saqib,

Sorry still not work.  I am hard headed today. :)

I forgot the file.

I am using excel 2003.

Thanks,
JP Username-in-formula.xls
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35177035
Check this file

Saqib
Copy-of-Username-in-formula.xls
0
 

Author Comment

by:easycapital
ID: 35177049
I see that you added the code in the module section; so I am assuming that is where I need place the code?

If I was to export sheet one, will it take with it the module code?  That is why I thought I should paste code in the Sheet 1 VBA section.

Thanks,
JP
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35177080
Ok then use this code

Private Sub Worksheet_Change(ByVal Target As Range)
Range("usrname") = Environ("username")
End Sub

and name the desired cell "usrname" from the insert > name > define

Saqib
0
 

Author Comment

by:easycapital
ID: 35177096
Let me think about it.  Using name ranges could cause  a problem is the other sheet has the same name range.

Thanks,
JP
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 35177114
then change

Range("usrname")

to something like

me.range("A1")
0
 

Author Closing Comment

by:easycapital
ID: 35203627
Thanks,
Jp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now