Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to add username in excel
Hello,
I hope you guys can help me. Im currently working in excel sheet. I would like to know tha formula where the shee should capture the username from the system or the licence which allocated to the user. What is the function or vb formula? Thank you in advanced. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to add username in excel
If you're using C#...
rangeXX.Value2 = Environment.UserName; "Dave VB logic for excel" wrote: Hello, I hope you guys can help me. Im currently working in excel sheet. I would like to know tha formula where the shee should capture the username from the system or the licence which allocated to the user. What is the function or vb formula? Thank you in advanced. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to add username in excel
Here are a couple of alternatives. The simplest way is
Dim UserName as string UserName = Environ("USERNAME") Here is another way to retrieve the user's LAN ID using an API call. Copy this code into a general VBA module in your workbook: Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long Public Function UserName() As String Dim Buffer As String * 100 Dim BuffLen As Long On Error GoTo UNerr BuffLen = 100 GetUserName Buffer, BuffLen UserName = Left(Buffer, BuffLen - 1) Exit Function UNerr: UserName = vbNullString End Function You would call it like this in VBA: Sub AAAAA() MsgBox UserName() End Sub Or, from a worksheet cell: =UserName() Finally, you could also try retrieving Application.UserName, which is the name entered on the Tools Options General tab. If you are new to user-defined functions (macros), this link to Jon Peltier's site may be helpful: http://peltiertech.com/WordPress/200...e-elses-macro/ Hope this helps, Hutch "Dave VB logic for excel" wrote: Hello, I hope you guys can help me. Im currently working in excel sheet. I would like to know tha formula where the shee should capture the username from the system or the licence which allocated to the user. What is the function or vb formula? Thank you in advanced. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Username in Excel - Paste Value? | Excel Worksheet Functions | |||
Excel Cell Comments Username does not appear | Excel Discussion (Misc queries) | |||
Excel Access query with username/pw | Excel Programming | |||
How can I print the username or computername from excel? | Excel Discussion (Misc queries) | |||
Looking for network-username with Excel macro | Excel Programming |