Solved

Formual to bring windows username (excel 2003)

Posted on 2011-03-20
13
204 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

24 Experts available now in Live!

Get 1:1 Help Now