I know this is an older thread. I'm doing something similiar to this, but when I copy this code into mine, I'm getting an error. My unique column is F which is called "INI Record" instead of A. This is how I modified the code to try and make it work for mine:
Code:
Sub Foo()
Dim c As Range
Dim rng As Range
Dim LR As Long
LR = Cells(Rows.Count, "R").End(xlUp).Row
Set rng = Range("F1:FJ" & LR)
Range("F1:F" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AM1"), Unique:=True
For Each c In Range([AM2], Cells(Rows.Count, "AM").End(xlUp))
With rng
.AutoFilter
.AutoFilter Field:=5, Criteria1:=c.Value
.SpecialCells(xlCellTypeVisible).Copy
Sheets.Add(After:=Sheets(Sheets.Count)).Name = c.Value
ActiveSheet.Paste
End With
Next c
End Sub
When I run the code, I get an error of "Run-time error '1004': Application-defined or object-defined error"
Here is a paste of a few rows of what my spreadsheet looks like:
[TABLE="class: grid, width: 4740"]
<tbody>[TR]
[TD]
Incident Ticket #[/TD]
[TD]
Change Ticket #[/TD]
[TD]
Build Summary[/TD]
[TD]
Builder[/TD]
[TD]
Action[/TD]
[TD]
INI Record[/TD]
[TD]
INI ID[/TD]
[TD]
D/C Adv Opt Item #[/TD]
[TD]
Record Name[/TD]
[TD]
Clinic(s)[/TD]
[TD]
Specialty[/TD]
[TD]
BLD Date[/TD]
[TD]
BLD Validator[/TD]
[TD]
STG Date[/TD]
[TD]
STG Data Courier[/TD]
[TD]
STG Validator[/TD]
[TD]
MST Date[/TD]
[TD]
REF Date[/TD]
[TD]
PRD Date[/TD]
[TD]
PRD Data Courier[/TD]
[TD]
PRD Validator[/TD]
[TD]
Comments[/TD]
[TD]
Issue ID[/TD]
[TD]
Item Type[/TD]
[/TR]
[TR]
[TD]356381[/TD]
[TD]24926[/TD]
[TD]Modified immunization and added Do not require[/TD]
[TD]LEVY, REID[/TD]
[TD]MODIFIED[/TD]
[TD]EAP - PROCEDURE[/TD]
[TD]280208[/TD]
[TD]880[/TD]
[TD]TD VACCINE PRESERVATIVE FREE =>7YO IM[/TD]
[TD]ALL[/TD]
[TD]ALL[/TD]
[TD="align: right"]6/5/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/5/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD="align: right"]6/5/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/5/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD]1[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]356381[/TD]
[TD]24926[/TD]
[TD]Modified immunization and added Do not require[/TD]
[TD]LEVY, REID[/TD]
[TD]MODIFIED[/TD]
[TD]EAP - PROCEDURE[/TD]
[TD]280198[/TD]
[TD]880[/TD]
[TD]ROTAVIRUS VACCINE PENTAVALENT 3 DOSE ORAL[/TD]
[TD]ALL[/TD]
[TD]ALL[/TD]
[TD="align: right"]6/5/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/5/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD="align: right"]6/5/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/5/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD]2[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]356381[/TD]
[TD]24926[/TD]
[TD]Modified immunization and added Do not require[/TD]
[TD]LEVY, REID[/TD]
[TD]MODIFIED[/TD]
[TD]EAP - PROCEDURE[/TD]
[TD]280150[/TD]
[TD]880[/TD]
[TD]HIB PRP-OMP CONJUGATE VACCINE 3 DOSE IM[/TD]
[TD]ALL[/TD]
[TD]ALL[/TD]
[TD="align: right"]6/5/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/5/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD="align: right"]6/5/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/5/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD]3[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]232868[/TD]
[TD]24777[/TD]
[TD]Change setting for Dual Mode Ordering Default to "Outpatient"[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD]MODIFIED[/TD]
[TD]DEP - DEPARTMENT[/TD]
[TD]26602[/TD]
[TD]17530[/TD]
[TD]GME FAMILY MED AT MHCD[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]4/25/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD]4[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]356669[/TD]
[TD]24964[/TD]
[TD]Update follow up with correct encounter report [/TD]
[TD]PAGE, ANNA[/TD]
[TD]MODIFIED[/TD]
[TD]LPR - EPICCARE PROFILES[/TD]
[TD]400000[/TD]
[TD]10007[/TD]
[TD]EH SYSTEM DEF[/TD]
[TD]ALL[/TD]
[TD]ALL[/TD]
[TD="align: right"]6/6/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FRAZZINI, MICHAEL[/TD]
[TD]CUSHMAN, SEE[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FRAZZINI, MICHAEL[/TD]
[TD]CUSHMAN, SEE[/TD]
[TD] [/TD]
[TD]5[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]356669[/TD]
[TD]24964[/TD]
[TD]add charge print groups to encounter report[/TD]
[TD]PAGE, ANNA[/TD]
[TD]MODIFIED[/TD]
[TD]LRP - REPORTS[/TD]
[TD]2103000102[/TD]
[TD]500[/TD]
[TD]HN VISIT SUMMARY: ANTICOAGULATION CHECK[/TD]
[TD]ALL[/TD]
[TD]ALL[/TD]
[TD="align: right"]6/6/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FRAZZINI, MICHAEL[/TD]
[TD]CUSHMAN, SEE[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FRAZZINI, MICHAEL[/TD]
[TD]CUSHMAN, SEE[/TD]
[TD] [/TD]
[TD]6[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]356669[/TD]
[TD]24964[/TD]
[TD]add charge print groups to encounter report[/TD]
[TD]PAGE, ANNA[/TD]
[TD]MODIFIED[/TD]
[TD]LRP - REPORTS[/TD]
[TD]20151111[/TD]
[TD]500[/TD]
[TD]EH AMB VISIT SUMMARY:W/O HISTORY[/TD]
[TD]ALL[/TD]
[TD]ALL[/TD]
[TD="align: right"]6/6/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FRAZZINI, MICHAEL[/TD]
[TD]CUSHMAN, SEE[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FRAZZINI, MICHAEL[/TD]
[TD]CUSHMAN, SEE[/TD]
[TD] [/TD]
[TD]7[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]24949[/TD]
[TD]update LPF with Lab Orders[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD]MODIFIED[/TD]
[TD]LPF - PREFERENCE LISTS[/TD]
[TD]210312038[/TD]
[TD] [/TD]
[TD]HN MT SVB LAB FACILITY[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD]BERRY, JOAN[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD] [/TD]
[TD]9[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]24963[/TD]
[TD]update LPF with Lab Orders[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD]MODIFIED[/TD]
[TD]LPF - PREFERENCE LISTS[/TD]
[TD]210311974[/TD]
[TD] [/TD]
[TD]HN MT HRH LAB FACILITY[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2001[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD]BERRY, JOAN[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FIMBREZ, JIM[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD] [/TD]
[TD]10[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]317375[/TD]
[TD] [/TD]
[TD]Added department to LWS record[/TD]
[TD]WEST, JEFFREY[/TD]
[TD]MODIFIED[/TD]
[TD]LWS - WORKSTATION REGISTRY[/TD]
[TD]26264[/TD]
[TD]manual[/TD]
[TD]MPF051[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/3/2013[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/3/2013[/TD]
[TD] [/TD]
[TD]WEST, JEFFREY[/TD]
[TD] [/TD]
[TD]11[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]317375[/TD]
[TD] [/TD]
[TD]Added department to LWS record[/TD]
[TD]WEST, JEFFREY[/TD]
[TD]MODIFIED[/TD]
[TD]LWS - WORKSTATION REGISTRY[/TD]
[TD]26265[/TD]
[TD]manual[/TD]
[TD]MFP052[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/3/2013[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/3/2013[/TD]
[TD] [/TD]
[TD]WEST, JEFFREY[/TD]
[TD] [/TD]
[TD]12[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]317375[/TD]
[TD] [/TD]
[TD]Added department to LWS record[/TD]
[TD]WEST, JEFFREY[/TD]
[TD]MODIFIED[/TD]
[TD]LWS - WORKSTATION REGISTRY[/TD]
[TD]26266[/TD]
[TD]manual[/TD]
[TD]MFP053[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/3/2013[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/3/2013[/TD]
[TD] [/TD]
[TD]WEST, JEFFREY[/TD]
[TD] [/TD]
[TD]13[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD]357317, 356691, 357743[/TD]
[TD]24985[/TD]
[TD]update LPF with Lab Orders[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD]MODIFIED[/TD]
[TD]LPF - PREFERENCE LISTS[/TD]
[TD]210312041[/TD]
[TD] [/TD]
[TD]HN CO SMG LAB FACILITY PREF LIST[/TD]
[TD]SAINT MARY - GRAND JUNCTION, CO[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]SAYRE, CATHERINE[/TD]
[TD]KLEPFER, DENISE[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]FRAZZINI, MICHAEL[/TD]
[TD]KLEPFER, DENISE[/TD]
[TD] [/TD]
[TD]14[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]24987[/TD]
[TD]Change setting to "Never require" for NDC requirement behavior[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD]MODIFIED[/TD]
[TD]DEP - DEPARTMENT[/TD]
[TD]51001[/TD]
[TD]17590[/TD]
[TD]SVPN ABSAROKEE MED CL[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD]15[/TD]
[TD]Item[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]24987[/TD]
[TD]Change setting to "Never require" for NDC requirement behavior[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD]MODIFIED[/TD]
[TD]DEP - DEPARTMENT[/TD]
[TD]51006[/TD]
[TD]17590[/TD]
[TD]SVPN LONG TERM CARE[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]6/6/2013[/TD]
[TD]BERRY, JOAN[/TD]
[TD]MUELLER, CHARISSA[/TD]
[TD] [/TD]
[TD]16[/TD]
[TD]Item[/TD]
[/TR]
</tbody><colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col span="2"><col><col><col><col span="2"><col><col><col></colgroup>[/TABLE]
Any help will be greatly appreciated.
Michael M.