easycapital
asked on
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
but I would like to display it via a formula.
Thanks,
JP
ASKER
Should I type some additional code such as Sub...
Thanks,
JP
Thanks,
JP
No Just paste the function...end function in a module
and enter the formula =usrname in the worksheet
and enter the formula =usrname in the worksheet
sorry, usrname()
ASKER
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
Thanks,
JP
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
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
ASKER
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
Sorry still not work. I am hard headed today. :)
I forgot the file.
I am using excel 2003.
Thanks,
JP Username-in-formula.xls
ASKER
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
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
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
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
ASKER
Let me think about it. Using name ranges could cause a problem is the other sheet has the same name range.
Thanks,
JP
Thanks,
JP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks,
Jp
Jp
=usrname()
and the code behind the function is
Function usrname()
usrname = Environ("username")
End Function
Saqib