Selected Answer
Hi ANSCOM
Like Willie (but with Excel365), I ran the code from the button and didn't get that error 5 (and the code created a new sheets "aa1" and "dd1")
(I note that Sheet1 has duplicate supplier values aa1 in B6 and B11- if you change B11 to ab1 say, you'll get summary sheet for ab1 too.)
That said, that's because your macro test1 contains several lines for On Error.... (not sure why you need the duplicates!) which would mask any error. If I comment all these lines out, I get run error '457' on line:
z.Add Array(a(i, 2), CreateObject("System.Collections.Arraylist")), CStr(a(i, 2))
related to a duplicate key- like the second aa1 (which might be avoided by checking first with IsObject before doing an Add to the Collection z)).
Likewise, there's also an Error 9 related to this line:
Sheets(z(i)(0)).Delete
where I guess you're trying to delete a sheet number which does not exist- please check.
If this sorts your problem, please remember to mark ths Answer as Selected. If not and you still get Error 5, please tell us on which line it occurs (using the Debug button). Step through the code if necessary.