Hi all - first, let me say this is an enormously helpful forum! For weeks I've found every answer I needed without even registering. I will be sure to contribute back as/when I'm able!
I have an issue using a variable as a worksheet name. I have code finding the first name of a user from Application.Username, and then I want to call a worksheet specific to this person. Current code:
Dim UName As String
Dim unameSplit As Variant
Dim UFN As String
UName = Application.UserName
unameSplit = Split(UName, ",")
UFN = unameSplit(1)
Set wstemp = Sheets(UFN)
I currently get error "Subscript out of range" when running. If I change wstemp to Sheets("Peter") it works however. What am I doing wrong?
I have an issue using a variable as a worksheet name. I have code finding the first name of a user from Application.Username, and then I want to call a worksheet specific to this person. Current code:
Dim UName As String
Dim unameSplit As Variant
Dim UFN As String
UName = Application.UserName
unameSplit = Split(UName, ",")
UFN = unameSplit(1)
Set wstemp = Sheets(UFN)
I currently get error "Subscript out of range" when running. If I change wstemp to Sheets("Peter") it works however. What am I doing wrong?