I have data set that contains ID numbers on Column A that repeat multiple times and vary from ID # to ID #. For example ID # 123 may take up 17 rows, while ID # 456 may take up 5 rows.

To add complexity, within each ID #'s rows, there are two types of data they can fall under (i.e. ID # 123 (from above example) - 10 of those rows go under "Table 1" in Word Document and the other 7 rows go under "Table 2". I have a Column (Column B) in the Excel data that identifies which Table in Word that row is supposed to go under.

Excel data is sorted by Column A, then by Column B so that all ID #'s and all table data are next to each other.

I have successfully been able to write to Word and the macro distinguish between putting data between Table 1 or 2, but only do this for one single ID #'s data (i.e. Excel wrote to Word for ID # 123 and placed 10 rows on "Table 1" and 7 rows on "Table 2") and save the Word Document as ID # 123.

What I am having trouble with is then creating a new file for ID # 456 and restarting the distingushing process between data going to "Table 1"or "Table 2".

If I run a while ID # is the same loop the macro creates 17 Word Documents for ID # 123, and 5 Word documents for ID # 456. How can I make the macro wirte two Word Documents, rather than 22?