Solved

Formual to bring windows username (excel 2003)

Posted on 2011-03-20
13
206 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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
 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

776 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