I have a form for work that requires an employee's name. I have a data validation so we can simply choose from a list, but is there a way to fill the cell automatically, upon opening the file? We each access the company network every time we log onto a company computer, and each of our user data are unique.
I have the Employee ID set to autofill (via a table and a vlookup) as soon as Driver Name is chosen from the drop-down list, but I would like for users to be able to open the file and have their name autofill based on their user info, thereby also filling the EID so they can print out the sheet more quickly.
If there isn't this kind of functionality in excel, that's fine, I just want to know.
I'm not sure what to put here, because I haven't been able to find anything on google, so I haven't actually tried anything yet. I don't know if it's certain syntax that I need to use (like when saving files to specific domains/folders) or if there's some other included functionality I'm just not aware of.
I'm gonna look up application.username once I get back to work tonight, like @freddy suggested
CodePudding user response:
So here is what I did:
First, I combined Application.Username with MsgBox to find my username
Sub GetUser()
MsgBox Application.UserName
End Sub
Then, after realizing that my username was just how we search for people within Outlook, I coded an If-Then statement
Sub IfUserThen()
If Application.UserName = "EXT-Last, First M" Then
Range("A!X5").Value = "Last"
End If
End Sub
Then to make it automatic on open, I coded in ThisWorkbook
Private Sub Workbook_Open()
Call IfUserThen
End Sub
I have way more names, but didn't list them for sake of brevity. Thanks for all the help everyone.