inserting current windows user id into a cell

  • Thread starter Thread starter MartyMack74
  • Start date Start date
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.
 
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
 
Hi,

Try this

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

Mike
 
Back
Top