I have a macro that works when I have a data set that is about 1,500 rows or less. When I run the marcro on a data set with 2,000+ rows, I get the error 'Runtime error 9: Subscript out of range.' It errors on this line:
Any ideas?
Code:
l = Sheets(CStr(y)).Cells(Rows.Count, "O").End(xlUp).Row + 1
Any ideas?
Code:
Sub Download()
Dim x As Long
Dim y As String
Dim r As Range
Dim l As Long
ActiveSheet.Name = "Download"
Range("E:E,G:G,H:H,K:K,M:M,O:O,P:P,U:U,Y:Y,Z:Z,AA:AC").Delete
Worksheets.Add.Name = "Managers"
Worksheets.Add.Name = "Assistant Managers 1"
Worksheets.Add.Name = "Assistant Managers 2"
Worksheets.Add.Name = "Team Leaders"
Worksheets.Add.Name = "Team Members"
Worksheets("Download").Select
x = 2
Do Until x > Sheets("Download").UsedRange.Rows.Count
y = Sheets("Download").Cells(x, 15).Value
Set r = Range("A" & x).EntireRow
l = Sheets(CStr(y)).Cells(Rows.Count, "O").End(xlUp).Row + 1
r.EntireRow.Copy Sheets(CStr(y)).Range("A" & l)
x = x + 1
Loop
End Sub