inserting current windows user id into a cell

M

MartyMack74

Does anyone know of a function or macro that will allow the current windows
userid to be displayed in a cell such as: "Printed by: userid"? Any help is
greatly appreciated.
 
R

Ron Rosenfeld

Does anyone know of a function or macro that will allow the current windows
userid to be displayed in a cell such as: "Printed by: userid"? Any help is
greatly appreciated.

Here is a User Defined Function:

To enter this User Defined Function (UDF), <alt-F11> opens the Visual Basic
Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this User Defined Function (UDF), enter a formula like

="Printed by: " & User()

in some cell.

==============================
Function User()
User = Application.UserName
End Function
=============================
--ron
 
M

Mike H

Hi,

Try this

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets("Sheet1").Range("A1") = "Printed by " & Environ("Username")
End Sub

Mike
 

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