Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Insert user's logon name in to cell in worksheet

I want to insert the Environ("User Name") in to cell B71, not sure how I go
about that?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert user's logon name in to cell in worksheet


Hello Ivory_Kitten,

VBA makes this information available through the global cal
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to projec
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code
-------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=56190

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Insert user's logon name in to cell in worksheet

I'm sorry, I don't speak your language. Do you know english?

"Francisco Parrilla" wrote:

Hi

Sub InfoDeWindows()
With CreateObject("WScript.Network")
MsgBox "Por Windows_Scripting:" & vbCr & _
"Nombre del equipo: " & .ComputerName & vbCr & _
"Nombre del dominio: " & .UserDomain & vbCr & _
"Nombre del usuario: " & .UserName & vbCr & vbCr & _
"Por variables del entorno:" & vbCr & _
"Nombre del equipo: " & Environ("computername") & vbCr & _
"Nombre del dominio: " & Environ("userdomain") & vbCr & _
"Nombre del usuario: " & Environ("username")
End With
End Sub

Saludos :)
Atte.
?T Francisco T?
http://groups.msn.com/ExcelVbaMacrosOffice
http://groups.msn.com/dadyboy
http://search.microsoft.com/?mkt=es-ES

"El progreso debe ser un movimiento ordenado y racional hacia una meta
fija... y no un torbellino de direcciones falsas y encontradas."





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Insert user's logon name in to cell in worksheet

You should be able to tell from the code what each part of information is
referring to.
Just change the Spanish text to whatever you want in English.
Or translate it: http://babelfish.altavista.com/tr

NickHK

"ivory_kitten" wrote in message
...
I'm sorry, I don't speak your language. Do you know english?

"Francisco Parrilla" wrote:

Hi

Sub InfoDeWindows()
With CreateObject("WScript.Network")
MsgBox "Por Windows_Scripting:" & vbCr & _
"Nombre del equipo: " & .ComputerName & vbCr & _
"Nombre del dominio: " & .UserDomain & vbCr & _
"Nombre del usuario: " & .UserName & vbCr & vbCr & _
"Por variables del entorno:" & vbCr & _
"Nombre del equipo: " & Environ("computername") & vbCr

& _
"Nombre del dominio: " & Environ("userdomain") & vbCr

& _
"Nombre del usuario: " & Environ("username")
End With
End Sub

Saludos :)
Atte.
?T Francisco T?
http://groups.msn.com/ExcelVbaMacrosOffice
http://groups.msn.com/dadyboy
http://search.microsoft.com/?mkt=es-ES

"El progreso debe ser un movimiento ordenado y racional hacia una meta
fija... y no un torbellino de direcciones falsas y encontradas."







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Insert user's logon name in to cell in worksheet

Thanks for the simple solution, that works perfectly!

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=561907




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Insert user's logon name in to cell in worksheet

Hi

Sub InfoDeWindows()
With CreateObject("WScript.Network")
MsgBox "Por Windows_Scripting:" & vbCr & _
"Nombre del equipo: " & .ComputerName & vbCr & _
"Nombre del dominio: " & .UserDomain & vbCr & _
"Nombre del usuario: " & .UserName & vbCr & vbCr & _
"Por variables del entorno:" & vbCr & _
"Nombre del equipo: " & Environ("computername") & vbCr & _
"Nombre del dominio: " & Environ("userdomain") & vbCr & _
"Nombre del usuario: " & Environ("username")
End With
End Sub

Saludos :)
Atte.
?T Francisco T?
http://groups.msn.com/ExcelVbaMacrosOffice
http://groups.msn.com/dadyboy
http://search.microsoft.com/?mkt=es-ES

"El progreso debe ser un movimiento ordenado y racional hacia una meta
fija... y no un torbellino de direcciones falsas y encontradas."




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Insert user's logon name in to cell in worksheet

All you need is

Public Function UserName() As String
Application.Volatile
UserName = Environ("UserName")
End Function

It is not a good idea to use APplication.Username as the user can change
that, there is no consistency. On a network, the login name is usually
protected against change by an individual.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"ivory_kitten" wrote in message
...
I'm sorry, I don't speak your language. Do you know english?

"Francisco Parrilla" wrote:

Hi

Sub InfoDeWindows()
With CreateObject("WScript.Network")
MsgBox "Por Windows_Scripting:" & vbCr & _
"Nombre del equipo: " & .ComputerName & vbCr & _
"Nombre del dominio: " & .UserDomain & vbCr & _
"Nombre del usuario: " & .UserName & vbCr & vbCr & _
"Por variables del entorno:" & vbCr & _
"Nombre del equipo: " & Environ("computername") & vbCr

& _
"Nombre del dominio: " & Environ("userdomain") & vbCr

& _
"Nombre del usuario: " & Environ("username")
End With
End Sub

Saludos :)
Atte.
?T Francisco T?
http://groups.msn.com/ExcelVbaMacrosOffice
http://groups.msn.com/dadyboy
http://search.microsoft.com/?mkt=es-ES

"El progreso debe ser un movimiento ordenado y racional hacia una meta
fija... y no un torbellino de direcciones falsas y encontradas."







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Insert user's logon name in to cell in worksheet

It's only working on my computer, when other users try to open my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=561907


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Insert user's logon name in to cell in worksheet

Where did place the code for the username function ?
In the WB you sent them ?
Or in Personal.xls ?

NickHK

"ivory_kitten" wrote in message
...
It's only working on my computer, when other users try to open my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=561907




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Insert user's logon name in to cell in worksheet

In a module in the worksheet

"NickHK" wrote:

Where did place the code for the username function ?
In the WB you sent them ?
Or in Personal.xls ?

NickHK

"ivory_kitten" wrote in message
...
It's only working on my computer, when other users try to open my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=561907







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Insert user's logon name in to cell in worksheet

In a separate module or in a worksheet ?
The function must be in a module (not on a worksheet) and Public to use it
on a worksheet.

NickHK

"ivory_kitten" wrote in message
...
In a module in the worksheet

"NickHK" wrote:

Where did place the code for the username function ?
In the WB you sent them ?
Or in Personal.xls ?

NickHK

"ivory_kitten" wrote in message
...
It's only working on my computer, when other users try to open my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to

project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross

------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=561907







  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Insert user's logon name in to cell in worksheet

My VBAProject is (CostCalculator.xlt) and the username function is in the
Modules folder, and is called Module1

This is the code which exists in Module1

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

"NickHK" wrote:

In a separate module or in a worksheet ?
The function must be in a module (not on a worksheet) and Public to use it
on a worksheet.

NickHK

"ivory_kitten" wrote in message
...
In a module in the worksheet

"NickHK" wrote:

Where did place the code for the username function ?
In the WB you sent them ?
Or in Personal.xls ?

NickHK

"ivory_kitten" wrote in message
...
It's only working on my computer, when other users try to open my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to

project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross

------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread:
http://www.excelforum.com/showthread...hreadid=561907








  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Insert user's logon name in to cell in worksheet

What security setting do they use ?
Is the being fired at all ?
So if they enter "=UserName()" in a worksheet cell, what is the result ?

A few more details would help, instead of only "does not work".

NickHK

"ivory_kitten" wrote in message
...
My VBAProject is (CostCalculator.xlt) and the username function is in the
Modules folder, and is called Module1

This is the code which exists in Module1

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

"NickHK" wrote:

In a separate module or in a worksheet ?
The function must be in a module (not on a worksheet) and Public to use

it
on a worksheet.

NickHK

"ivory_kitten" wrote in message
...
In a module in the worksheet

"NickHK" wrote:

Where did place the code for the username function ?
In the WB you sent them ?
Or in Personal.xls ?

NickHK

"ivory_kitten" wrote in

message
...
It's only working on my computer, when other users try to open my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to

project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross


------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread:
http://www.excelforum.com/showthread...hreadid=561907










  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Insert user's logon name in to cell in worksheet

Macro Security is set to Low as we have Virus protection. When they open the
spreadsheet the field contains the data =username(). The result displayed in
the cell is #NAME!.

"NickHK" wrote:

What security setting do they use ?
Is the being fired at all ?
So if they enter "=UserName()" in a worksheet cell, what is the result ?

A few more details would help, instead of only "does not work".

NickHK

"ivory_kitten" wrote in message
...
My VBAProject is (CostCalculator.xlt) and the username function is in the
Modules folder, and is called Module1

This is the code which exists in Module1

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

"NickHK" wrote:

In a separate module or in a worksheet ?
The function must be in a module (not on a worksheet) and Public to use

it
on a worksheet.

NickHK

"ivory_kitten" wrote in message
...
In a module in the worksheet

"NickHK" wrote:

Where did place the code for the username function ?
In the WB you sent them ?
Or in Personal.xls ?

NickHK

"ivory_kitten" wrote in

message
...
It's only working on my computer, when other users try to open my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module to
project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross


------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread:
http://www.excelforum.com/showthread...hreadid=561907











  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Insert user's logon name in to cell in worksheet

That means Excel cannot find the function "UserName", so the code is NOT on
a module, but on a worksheet or class module.
Move the code to a module in the WB in which it is used.

NickHK

"ivory_kitten" wrote in message
...
Macro Security is set to Low as we have Virus protection. When they open

the
spreadsheet the field contains the data =username(). The result displayed

in
the cell is #NAME!.

"NickHK" wrote:

What security setting do they use ?
Is the being fired at all ?
So if they enter "=UserName()" in a worksheet cell, what is the result ?

A few more details would help, instead of only "does not work".

NickHK

"ivory_kitten" wrote in message
...
My VBAProject is (CostCalculator.xlt) and the username function is in

the
Modules folder, and is called Module1

This is the code which exists in Module1

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

"NickHK" wrote:

In a separate module or in a worksheet ?
The function must be in a module (not on a worksheet) and Public to

use
it
on a worksheet.

NickHK

"ivory_kitten" wrote in

message
...
In a module in the worksheet

"NickHK" wrote:

Where did place the code for the username function ?
In the WB you sent them ?
Or in Personal.xls ?

NickHK

"ivory_kitten" wrote in

message
...
It's only working on my computer, when other users try to open

my
spreadsheet, the username function does not work!?

"Leith Ross" wrote:


Hello Ivory_Kitten,

VBA makes this information available through the global call
Application.UserName. The value returned is a string.

Here is a UDF you can use. You will need to add a VBA module

to
project
and place this code in it before you can use it.

1) Copy the code uing CTRL+C.
2) Open the Workbook you will be using.
3) Press ALT+F11 to open the VBA Editor
4) Press ALT+I to activate the Insert Menu.
5) Press M to insert a new Module into the Workbook.
6) Press CTRL+V to paste the code into the Module.
7) Press CTRL+S to save the Macro.
8) Press ALT+Q to close the VBA Editor.


Code:
--------------------

Public Function UserName() As String
Application.Volatile
UserName = Application.UserName
End Function

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


B71 formula =UserName()
B71 will now show the name of the user currently logged on.

Sincerely,
Leith Ross


--
Leith Ross



------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread:
http://www.excelforum.com/showthread...hreadid=561907













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
Can I pass network logon name to a cell in a spreadsheet? Quality Plan Excel Worksheet Functions 5 December 4th 08 07:38 AM
copy worksheet multiple times base on user's input [email protected] Excel Worksheet Functions 2 June 15th 07 05:51 PM
How do I populate a cell with the NT Logon username? Mike Excel Discussion (Misc queries) 1 June 3rd 05 07:58 AM
insert a user's name/id benb Excel Discussion (Misc queries) 1 January 10th 05 08:05 PM
Logon to Worksheet John Wilson Excel Programming 1 August 15th 03 07:18 PM


All times are GMT +1. The time now is 02:15 PM.

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

About Us

"It's about Microsoft Excel"