Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Username in Excel - Paste Value? NPell Excel Worksheet Functions 15 June 25th 08 08:54 AM
Excel Cell Comments Username does not appear William Excel Discussion (Misc queries) 1 June 11th 08 11:33 AM
Excel Access query with username/pw Gsimmons2005 Excel Programming 3 August 15th 06 05:30 AM
How can I print the username or computername from excel? YesNo Excel Discussion (Misc queries) 0 March 9th 05 06:03 PM
Looking for network-username with Excel macro Geert Nauta Excel Programming 1 October 4th 04 04:12 PM


All times are GMT +1. The time now is 02:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"