• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Formual to bring windows username (excel 2003)

.. 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
easycapital
Asked:
easycapital
  • 7
  • 6
1 Solution
 
Saqib Husain, SyedEngineerCommented:
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
 
easycapitalAuthor Commented:
Should I type some additional code such as Sub...

Thanks,
JP
0
 
Saqib Husain, SyedEngineerCommented:
No Just paste the function...end function in a module

and enter the formula =usrname in the worksheet
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Saqib Husain, SyedEngineerCommented:
sorry, usrname()
0
 
easycapitalAuthor Commented:
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
 
Saqib Husain, SyedEngineerCommented:
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
 
easycapitalAuthor Commented:
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
 
Saqib Husain, SyedEngineerCommented:
Check this file

Saqib
Copy-of-Username-in-formula.xls
0
 
easycapitalAuthor Commented:
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
 
Saqib Husain, SyedEngineerCommented:
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
 
easycapitalAuthor Commented:
Let me think about it.  Using name ranges could cause  a problem is the other sheet has the same name range.

Thanks,
JP
0
 
Saqib Husain, SyedEngineerCommented:
then change

Range("usrname")

to something like

me.range("A1")
0
 
easycapitalAuthor Commented:
Thanks,
Jp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now