Hi Guys:
Got this one code, to Autofilter multiple values in a master sheets and copy each met criteria's to new sheet and named.
The code run nicely until it reaches the tenth sheet and system starts to prompted the error below.
Well I can't blame the system, since the list in the master sheet is huge.
Run Time error 1004. Application defined or object defined error.
Got this one code, to Autofilter multiple values in a master sheets and copy each met criteria's to new sheet and named.
The code run nicely until it reaches the tenth sheet and system starts to prompted the error below.
Well I can't blame the system, since the list in the master sheet is huge.
Run Time error 1004. Application defined or object defined error.
VBA Code:
'Start Here
Dim x As Long
Dim y As Long
Dim dic As Object
Dim arr() As Variant
Dim var As Variant
Dim rng As Range
Set dic = CreateObject("Scripting.Dictionary")
y = Range("AT1").Column
Application.ScreenUpdating = False
With Sheets("Export Worksheet")
arr = .Cells(6, 1).Resize(.Cells(.Rows.Count, 1).End(xlUp).Row - 5, y).Value
For x = LBound(arr, 1) To UBound(arr, 1)
Set rng = .Cells(x + 5, 1).Resize(, y)
If dic.exists(arr(x, 1)) Then Set rng = Union(dic(arr(x, 1)), rng)
Set dic(arr(x, 1)) = rng
Next x
End With
Erase arr
Set rng = Nothing
For Each var In dic
Sheets.Add(after:=Sheets(Sheets.Count)).Name = CStr(var)
With Sheets(CStr(var))
dic(var).Copy
.Cells(1, 1).PasteSpecial xlPasteAll
Application.CutCopyMode = False
End With
Next var
Application.ScreenUpdating = True
Set dic = Nothing
'End Here