Worksheet1
[TABLE="class: ydpf8f6d4a8wysiwyg_dashes, width: 1000"]
<tbody>[TR]
[TD]LastName[/TD]
[TD]FirstName[/TD]
[TD]Code[/TD]
[TD]ID[/TD]
[TD]E[/TD]
[TD]Group[/TD]
[TD]Address[/TD]
[TD]H[/TD]
[TD]Group2[/TD]
[TD]Address2[/TD]
[TD]K[/TD]
[TD]Group3[/TD]
[TD]Address3[/TD]
[/TR]
[TR]
[TD]Smith[/TD]
[TD]John[/TD]
[TD]01, 03[/TD]
[TD]123456[/TD]
[TD][/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD][/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[TD][/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[TD][/TD]
[TD]Place3[/TD]
[TD]567 High St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD][/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[TD][/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD][/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[TD][/TD]
[TD]Place4[/TD]
[TD]987 1st St.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Worksheet2
[TABLE="class: ydpf8f6d4a8wysiwyg_dashes, width: 500"]
<tbody>[TR]
[TD]LastName[/TD]
[TD]FirstName[/TD]
[TD]Code[/TD]
[TD]ID[/TD]
[TD]Group[/TD]
[TD]Address[/TD]
[/TR]
[TR]
[TD]Smith[/TD]
[TD]John[/TD]
[TD]01, 03[/TD]
[TD]123456[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I have original data structured like Worksheet1 above. In this example, columns E,H, and K are other data that is irrelevant. The Group field is a primary location, Group2 and Group3 are secondary and tertiary locations. I have already pulled out the data I need for the primary location into Worksheet2 (as shown above). I need to loop through the Group2 and then Group3 columns to find rows that have an existing value. If there is a value in Group2 or Group3, then copy specific cells to the bottom of the list on Worksheet2. The number of rows in Worksheet1 and Worksheet2 is always variable (there will be many future spreadsheets like this).
So - loop through Group2 column, when a value is found, copy the LastName, FirstName, Code, ID, Group2, and Address2 to the bottom of the Worksheet2 list (Group2 and Address2 will now appear in the Group and Address columns). Then do the same for the Group3 column.
The end results will look like this:
Worksheet2
[TABLE="class: ydpf8f6d4a8wysiwyg_dashes, width: 500"]
<tbody>[TR]
[TD]LastName[/TD]
[TD]FirstName[/TD]
[TD]Code[/TD]
[TD]ID[/TD]
[TD]Group[/TD]
[TD]Address[/TD]
[/TR]
[TR]
[TD]Smith[/TD]
[TD]John[/TD]
[TD]01, 03[/TD]
[TD]123456[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD]Place4[/TD]
[TD]987 1st St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place3[/TD]
[TD]567 High St.[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Thank you for any help you can give me on this!
[TABLE="class: ydpf8f6d4a8wysiwyg_dashes, width: 1000"]
<tbody>[TR]
[TD]LastName[/TD]
[TD]FirstName[/TD]
[TD]Code[/TD]
[TD]ID[/TD]
[TD]E[/TD]
[TD]Group[/TD]
[TD]Address[/TD]
[TD]H[/TD]
[TD]Group2[/TD]
[TD]Address2[/TD]
[TD]K[/TD]
[TD]Group3[/TD]
[TD]Address3[/TD]
[/TR]
[TR]
[TD]Smith[/TD]
[TD]John[/TD]
[TD]01, 03[/TD]
[TD]123456[/TD]
[TD][/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD][/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[TD][/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[TD][/TD]
[TD]Place3[/TD]
[TD]567 High St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD][/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[TD][/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD][/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[TD][/TD]
[TD]Place4[/TD]
[TD]987 1st St.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Worksheet2
[TABLE="class: ydpf8f6d4a8wysiwyg_dashes, width: 500"]
<tbody>[TR]
[TD]LastName[/TD]
[TD]FirstName[/TD]
[TD]Code[/TD]
[TD]ID[/TD]
[TD]Group[/TD]
[TD]Address[/TD]
[/TR]
[TR]
[TD]Smith[/TD]
[TD]John[/TD]
[TD]01, 03[/TD]
[TD]123456[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I have original data structured like Worksheet1 above. In this example, columns E,H, and K are other data that is irrelevant. The Group field is a primary location, Group2 and Group3 are secondary and tertiary locations. I have already pulled out the data I need for the primary location into Worksheet2 (as shown above). I need to loop through the Group2 and then Group3 columns to find rows that have an existing value. If there is a value in Group2 or Group3, then copy specific cells to the bottom of the list on Worksheet2. The number of rows in Worksheet1 and Worksheet2 is always variable (there will be many future spreadsheets like this).
So - loop through Group2 column, when a value is found, copy the LastName, FirstName, Code, ID, Group2, and Address2 to the bottom of the Worksheet2 list (Group2 and Address2 will now appear in the Group and Address columns). Then do the same for the Group3 column.
The end results will look like this:
Worksheet2
[TABLE="class: ydpf8f6d4a8wysiwyg_dashes, width: 500"]
<tbody>[TR]
[TD]LastName[/TD]
[TD]FirstName[/TD]
[TD]Code[/TD]
[TD]ID[/TD]
[TD]Group[/TD]
[TD]Address[/TD]
[/TR]
[TR]
[TD]Smith[/TD]
[TD]John[/TD]
[TD]01, 03[/TD]
[TD]123456[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD]Place1[/TD]
[TD]123 Main St.[/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD]White[/TD]
[TD]Barb[/TD]
[TD]03, 123, 04[/TD]
[TD]258787[/TD]
[TD]Place2[/TD]
[TD]345 Water St.[/TD]
[/TR]
[TR]
[TD]Collins[/TD]
[TD]Susan[/TD]
[TD]06, 03[/TD]
[TD]345214[/TD]
[TD]Place4[/TD]
[TD]987 1st St.[/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD]Fred[/TD]
[TD]06[/TD]
[TD]852547[/TD]
[TD]Place3[/TD]
[TD]567 High St.[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Thank you for any help you can give me on this!