I have a workbook that multiple people have their own copy of that has their Windows Username at the end of the file name (e.x. Test jdoe). Right now any time somebody new needs to use the workbook I have to manually update a few lines of code with their username. Here is an example.
When I run this I get Run-time error "9": Subscript out of range. I wondering what I am doing incorrectly. Any help would be appreciated
Thanks!
Code:
Dim a As Worksheet, WinUser As String
Application.ScreenUpdating = False
WinUser = Environ("USERNAME") ' Windows username
Set a = Workbooks("Test " & WinUser & ".xlsm").Sheets("Test")
a.Activate
When I run this I get Run-time error "9": Subscript out of range. I wondering what I am doing incorrectly. Any help would be appreciated
Thanks!