Hi forum, I am having a weird problem that I've been struggling for a couple of weeks now.
I have a list of employee names in Column A and a a For loop that sets the worksheet name ("wsName") to each cell value (employee names).
The macro works fine for the first 13 employees; on the 14th employee, I get Error 91. For whatever reason, on employee 14, it is not setting "wsName". The 14th employee name doesnt have any symbols or numbers.
Thanks in advance for your help!
I have a list of employee names in Column A and a a For loop that sets the worksheet name ("wsName") to each cell value (employee names).
The macro works fine for the first 13 employees; on the 14th employee, I get Error 91. For whatever reason, on employee 14, it is not setting "wsName". The 14th employee name doesnt have any symbols or numbers.
Code:
Dim wsSummary, wsName As Worksheet
Dim sName As String
Set wsSummary = ThisWorkbook.Worksheets("Summary")
With wsSummary[INDENT]For i = 1 to 25[/INDENT]
[INDENT] sName = .Range("A" & i).Value[/INDENT]
[INDENT=2]Set wsName = ThisWorkbook.Worksheets(sName)
With wsName[/INDENT]
[INDENT=3]'Some copy and paste stuff
End With[/INDENT]
[INDENT]
Next i[/INDENT]
End With
End Sub
Thanks in advance for your help!
Last edited: