View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
swieduwi
 
Posts: n/a
Default Including Environ Username in Cell


Roger Govier Wrote:
Hi
Where are you pasting the code?
It needs to be in a general module of the workbook you are using, not
in
the Sheet code.
--
Regards

Roger Govier

[/color]
Thanks for the reply...

Yes I placed it in the General section of my Workbook code area and it
looks like this:

Formula:
--------------------

Public Function UserName()

Select Case UCase(NameType)
Case Is = "OFFICE", "1"
GetName = Application.UserName
Exit Function
Case Is = "WINDOWS", "2"
GetName = Environ("UserName")
Exit Function
Case Is = "COMPUTER", "3"
GetName = Environ("ComputerName")
Exit Function
Case Else
GetName = CVErr(xlErrValue)
End Select

End Function

--------------------

in the cell I reference "=username()" I get a #REF! in the Cell
if I reference "=GetName(2) i get a #NAME?


--
swieduwi
------------------------------------------------------------------------
swieduwi's Profile: http://www.excelforum.com/member.php...o&userid=21962
View this thread: http://www.excelforum.com/showthread...hreadid=507221