SOLVED

Populate Username without VBA?

Copper Contributor

Is there a way to populate the Excel user's name in a cell w/o using VBA?

 

Trying an IF functio nthat would populate username if data is entered in a corresponding cell. However, I cannot use C:\Users because this is a shared workbook. Trying to avoid VBA due to security/automation challenges. Can I somehow pull the username from the Excel account info and populate using a formula?

 

Current formula: =IF(C2<>"",IF(E2="", LET(fullpath,INFO("DIRECTORY"),path,SUBSTITUTE(fullpath,"C:\Users\",""),LEFT(path,FIND("\",path)-1)),E2),"")

5 Replies
best response confirmed by Ashley315 (Copper Contributor)
Solution

@Ashley315 

For the shared workbook filepath could not include username at all.

Afraid that's with VBA.

@Sergei Baklan Thanks for confirming. Is there a way I can access the Excel Username and not the username from the file path? 

@Ashley315 

Please check excel - How to show current user name in a cell? - Stack Overflow It assumes you use desktop app and accept VBA.

are scripts allowed? they won't autorun or accessable using a function but can run on a button press and can get you the username that is logged in to excel.

Besides, won't that formula keep changing the "username" based on the folder it is in.  So even if you could do a trick to get the user name based on the user directory, as soon as someone else opens it the formula would update to that new persons name.  For a 1-time write option you really need either a macro or script or you can use power automate if you put it in sharepoint

Thank you. I have used the following VBA code below with success. I now need to add code that will unlock columns D & E so the macro can run, and then relock columns D & E once data is entered or deleted from Column C. Any ideas on the best way to achieve this?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
If Not Intersect(Target, Me.Range("C:C")) Is Nothing Then
For Each cell In Intersect(Target, Me.Range("C:C"))
If cell.Value <> "" Then
Me.Cells(cell.Row, "D").Value = Now()
Me.Cells(cell.Row, "E").Value = Application.UserName
Else
Me.Cells(cell.Row, "D").ClearContents
Me.Cells(cell.Row, "E").ClearContents
End If
Next cell
End If
End Sub
1 best response

Accepted Solutions
best response confirmed by Ashley315 (Copper Contributor)
Solution

@Ashley315 

For the shared workbook filepath could not include username at all.

Afraid that's with VBA.

View solution in original post