I am receiving the following error message when trying to pull names from column A into individual worksheets, Run-time error '1004': Application-defined or obeject-dfined error.
Here is part of the code
Here is part of the code
Code:
:Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$Y$3953").AutoFilter Field:=2, Criteria1:="#N/A"
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Sheet12").Select
ActiveSheet.Paste
Range("A1").Select
Columns("A:A").EntireColumn.AutoFit
Range("A1").Select
Sheets("Sheet12").Name = "UNASSIGNED VENDORS"
MySheet.Select
Range("A2").Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$2:$Y$5000").AutoFilter Field:=1, Criteria1:="=*HSBC*" _
, Operator:=xlAnd
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("A1").Select
Selection.AutoFilter
If MySheet.AutoFilterMode = False Then
Exit Sub
End If
Set MyRange = Range(MySheet.AutoFilter.Range.Columns(1).Address)
Set UList = New Collection
On Error Resume Next
For i = 2 To MyRange.Rows.Count
UList.Add MyRange.Cells(i, 1), CStr(MyRange.Cells(i, 1))
Next i
On Error GoTo 0
For Each UListValue In UList
On Error Resume Next
Application.DisplayAlerts = False
Sheets(CStr(UListValue)).Delete
Application.DisplayAlerts = True
On Error GoTo 0
MyRange.AutoFilter Field:=1, Criteria1:=UListValue
MySheet.AutoFilter.Range.Copy
Worksheets.Add.Paste
ActiveSheet.Name = Left(UListValue, 30)
Cells.EntireColumn.AutoFit
Next UListValue
MySheet.AutoFilter.ShowAllData
MySheet.Select
End Sub[\code]