VBA/Formula for Username

Mykiej23

New Member
Joined
Jun 2, 2016
Messages
22
Hi,

I am trying to get a formula that will generate whoever is inputting the reports username in a cell. After some research online, I've come across a VBA UDF but I'm not sure if I am doing it right.

I've tried creating a new module and adding the following:
VBA Code:
Function Username()
    Username = Environ$("USERNAME")
End Function

And then in the cell
=Username()

However, it will only generate my username, no matter who is doing the report. Have I missed something or is there something I can do to get this working?

Thank you for any help offered :)

Thanks,
Michaela
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
As the function is not volatile and has no precedent cells it will never be recalculated. If it was recalculated then it would show the name of the person viewing the report, which might not necessarily be the creator.

Assuming that the report is run in vba, I would suggest adding the username directly to the cell as part of that process as opposed to using a function / formula.
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,788
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top