Forum Discussion
Populate Username without VBA?
- Mar 13, 2024
For the shared workbook filepath could not include username at all.
Afraid that's with VBA.
SergeiBaklan Thanks for confirming. Is there a way I can access the Excel Username and not the username from the file path?
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
- Ashley315Mar 15, 2024Copper ContributorThank 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