What is the formula to capture username from system into excel she

  • Thread starter Dave VB logic for excel
  • Start date
D

Dave VB logic for excel

Hello,

im working on excel sheet which use by multiple user. I want a perticular
cell in sheet to capture the username whenever they open the sheet. i've
questioned this before and i was give the formula below. I tried copy paste
the formula into vb section of excel sheet but doesnt seem to work. In the
formula there's no cell reference. So where the system will capture the
username into xecel sheet?

Function UserNameWindows() As String
UserName = Environ("USERNAME")
End Function

Please help..
 
B

Bob Phillips

That is not a formula, that is a UDF. Add tat to a standarad VBA code
module, and in the worksheet in some cell add

=UserNameWindows()
 
D

dhstein

Dave, Bob,

I've been searching for this information - the "ENVIRON" statement that
you show below. I had an Access problem and now you helped me solve it - so
thank you. BTW the line should be UserNameWindows = Environ("USERNAME")
 
V

vinay tukkapuram

Sub Username()
Dim user As String
user = Application.Username
'MsgBox user
ActiveCell.Value = user
End Sub
 
V

vinay tukkapuram

Sub Username()
Dim user As String
user = Application.Username
'MsgBox user
ActiveCell.Value = user
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top