If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA for merging groups of Word table rows with data
I have a large one-column table in Word 2007 with names and addresses of individuals.
The table consumes over 80 pages because it consists of over 1000 of these individuals with their addresses. The addresses are either 2 or 3 rows, and there is always a blank row before and after each. There are never more then 2 consecutive blank rows; these will serve as separators for each Name and Address item. The table as it is now looks like the sample in "Original" below, which shows the records for 5 individuals, 4 of whom have 3 address lines and 1 of whom has 2 address lines (I have iterated the number for each name to show that the names and their addresses belong to separate people). These 2 and 3 address lines are random throughout the table. The "Target" is how I want the table to look, with the Name and Address lines merged, and with a blank row above each Name and after each last Address row. I have a simple macro that merges the rows when I select them 3 or 4 at a time; a macro to do the whole table at once would be great, but I have no idea how to write it. Suggestions welcome! Original: Row 1 Name1 Row 2 Address1 Row 3 Address2 Row 4 Address3 Row 5 blank Row 6 Name2 Row 7 Address1 Row 8 Address2 Row 9 Address3 Row 10 blank Row 11 Name3 Row 12 Address1 Row 13 Address2 Row 14 blank Row 15 Name4 Row 16 Address1 Row 17 Address2 Row 18 Address3 Row 19 blank Row 20 Name5 Row 21 Address1 Row 22 Address2 Row 23 Address3 Row 24 blank Target: Row 1 Name1 Address1 Address2 Address3 Row 2 blank Row 3 Name2 Address1 Address2 Address3 Row 4 blank Row 5 Name3 Address1 Address2 Row 8 blank Row 9 Name4 Address1 Address2 Address3 Row 10 blank Row 11 Name5 Address1 Address2 Address3 Row 12 blank |
Thread Tools | |
Display Modes | |
|
|