I have a table that looks like this:
[TABLE="width: 854"]
<tbody>[TR]
[TD]Company[/TD]
[TD]Invoice[/TD]
[TD] Amount 1[/TD]
[TD] Amount 2[/TD]
[TD] Amount 3[/TD]
[TD] Amount 4[/TD]
[TD] Amount 5[/TD]
[TD]Page[/TD]
[TD]Last Page[/TD]
[/TR]
[TR]
[TD]John Q Company[/TD]
[TD="align: right"]3063615[/TD]
[TD] $ 101[/TD]
[TD] $ 200[/TD]
[TD] $ 25[/TD]
[TD] $ 25[/TD]
[TD] $ 25[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Peter North Company[/TD]
[TD="align: right"]3063616[/TD]
[TD] $ 999[/TD]
[TD] $ 877[/TD]
[TD] $ 66[/TD]
[TD] $ 66[/TD]
[TD] $ 66[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 205[/TD]
[TD] $ 180[/TD]
[TD] $ 154[/TD]
[TD] $ 164[/TD]
[TD] $174[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 333[/TD]
[TD] $ 195[/TD]
[TD] $ 225[/TD]
[TD] $ 375[/TD]
[TD] $ 22[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 777[/TD]
[TD] $ 987[/TD]
[TD] $ 444[/TD]
[TD] $ 200[/TD]
[TD] $ 33[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 105[/TD]
[TD] $ 111[/TD]
[TD] $ 555[/TD]
[TD] $ 344[/TD]
[TD] $ 44[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 116[/TD]
[TD] $ 137[/TD]
[TD] $ 555[/TD]
[TD] $ 65[/TD]
[TD] $ 55[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 140[/TD]
[TD] $ 245[/TD]
[TD] $ 666[/TD]
[TD] $ 242[/TD]
[TD] $ 66[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 150[/TD]
[TD] $ 333[/TD]
[TD] $ 666[/TD]
[TD] $ 255[/TD]
[TD] $ 77[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063618[/TD]
[TD] $ 126[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]New York East Company[/TD]
[TD="align: right"]3063619[/TD]
[TD] $ 5,905[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
</tbody>[/TABLE]
I have a COUNTIF formula and a MAX formula that will count the number of repeating invoice numbers. So the last 2 columns are the page number and the last page number. I need some kind of VB code that will do a FOR NEXT (?) loop in the case of invoice 3063617 it will copy an existing worksheet call ADDPAGE and rename it to PAGE 2, 3, 4 for each of pages 2 thru 7. I also need to populate amount field on each page. Page 1 is already created and assumed for all invoices.
Any Ideas?
[TABLE="width: 854"]
<tbody>[TR]
[TD]Company[/TD]
[TD]Invoice[/TD]
[TD] Amount 1[/TD]
[TD] Amount 2[/TD]
[TD] Amount 3[/TD]
[TD] Amount 4[/TD]
[TD] Amount 5[/TD]
[TD]Page[/TD]
[TD]Last Page[/TD]
[/TR]
[TR]
[TD]John Q Company[/TD]
[TD="align: right"]3063615[/TD]
[TD] $ 101[/TD]
[TD] $ 200[/TD]
[TD] $ 25[/TD]
[TD] $ 25[/TD]
[TD] $ 25[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Peter North Company[/TD]
[TD="align: right"]3063616[/TD]
[TD] $ 999[/TD]
[TD] $ 877[/TD]
[TD] $ 66[/TD]
[TD] $ 66[/TD]
[TD] $ 66[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 205[/TD]
[TD] $ 180[/TD]
[TD] $ 154[/TD]
[TD] $ 164[/TD]
[TD] $174[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 333[/TD]
[TD] $ 195[/TD]
[TD] $ 225[/TD]
[TD] $ 375[/TD]
[TD] $ 22[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 777[/TD]
[TD] $ 987[/TD]
[TD] $ 444[/TD]
[TD] $ 200[/TD]
[TD] $ 33[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 105[/TD]
[TD] $ 111[/TD]
[TD] $ 555[/TD]
[TD] $ 344[/TD]
[TD] $ 44[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 116[/TD]
[TD] $ 137[/TD]
[TD] $ 555[/TD]
[TD] $ 65[/TD]
[TD] $ 55[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 140[/TD]
[TD] $ 245[/TD]
[TD] $ 666[/TD]
[TD] $ 242[/TD]
[TD] $ 66[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063617[/TD]
[TD] $ 150[/TD]
[TD] $ 333[/TD]
[TD] $ 666[/TD]
[TD] $ 255[/TD]
[TD] $ 77[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Sam South Company[/TD]
[TD="align: right"]3063618[/TD]
[TD] $ 126[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]New York East Company[/TD]
[TD="align: right"]3063619[/TD]
[TD] $ 5,905[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD] $ -[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
</tbody>[/TABLE]
I have a COUNTIF formula and a MAX formula that will count the number of repeating invoice numbers. So the last 2 columns are the page number and the last page number. I need some kind of VB code that will do a FOR NEXT (?) loop in the case of invoice 3063617 it will copy an existing worksheet call ADDPAGE and rename it to PAGE 2, 3, 4 for each of pages 2 thru 7. I also need to populate amount field on each page. Page 1 is already created and assumed for all invoices.
Any Ideas?