Hi,


I'm looking for a script that will auto-filter my Excel table by CustomerNumber then automatically copy and paste the filtered table into a Word doc. template I have saved on my computer (i.e. by defining a specific file pathway)

Once this has been done, I need the code to save and close the populated word template and move on to the next customer in my original excel table (i.e. the next unique customer number) and repeat the process so I am able to generate a unique word document from my template for each customer, with their specific details after filtering.

I've been researching auto-filter code, similar to the script below but can't get it execute within my code correctly.


For i = 1 To collUniqueHeadings.Count
    With wsSource
        .Range("A1").AutoFilter Field:=2, Criteria1:=collUniqueHeadings(i)
        .Range("A1:D" & lngLastRow).Copy
    End With
    With appWord.Selection
        .PasteExcelTable linkedtoexcel:=False, wordformatting:=True, RTF:=False
        .TypeParagraph
    End With
Next i
I've attached a workbook with an example of my data table and the code I've written so far.

Any help would be greatly appreciated.

Thanks,
Rex

Table Generator WorkBook.xlsm