VBA code to merge rows

dfolzenlogen

New Member
Joined
Oct 18, 2009
Messages
36
Hello,

I am trying to merge cells in rows based on the value of the cell in Column A of my spreadsheet (containing Document Type) through the continuous rows containing no Document Type in Column A [see below BEFORE and AFTER examples below]. This needs to loop through the entire spreadsheet.

BEFORE: [TABLE="width: 949"]
<tbody>[TR]
[TD="class: xl66, width: 86, bgcolor: #D6DCE4"]Book Type
[/TD]
[TD="class: xl66, width: 52, bgcolor: #D6DCE4"]Volume
[/TD]
[TD="class: xl66, width: 35, bgcolor: #D6DCE4"]Page
[/TD]
[TD="class: xl66, width: 256, bgcolor: #D6DCE4"]Subdivision
[/TD]
[TD="class: xl66, width: 29, bgcolor: #D6DCE4"]Lot
[/TD]
[TD="class: xl66, width: 39, bgcolor: #D6DCE4"]Block
[/TD]
[TD="class: xl66, width: 50, bgcolor: #D6DCE4"]Section
[/TD]
[TD="class: xl66, width: 152, bgcolor: #D6DCE4"]Survey
[/TD]
[TD="class: xl66, width: 53, bgcolor: #D6DCE4"]Abs No.
[/TD]
[TD="class: xl66, width: 256, bgcolor: #D6DCE4"]Grantor
[/TD]
[TD="class: xl66, width: 256, bgcolor: #D6DCE4"]Grantee
[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl64, width: 52, bgcolor: transparent"]1586
[/TD]
[TD="class: xl64, width: 35, bgcolor: transparent"]7
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOODLAND TRAILS

[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]4
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]3
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID ROY H
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]ROY REID BUILDING COMPANY
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 86, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 52, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 35, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID WILMA L
[/TD]
[TD="class: xl63, width: 256, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl64, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl64, width: 52, bgcolor: transparent"]1589
[/TD]
[TD="class: xl64, width: 35, bgcolor: transparent"]581
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOODLAND TRAILS
[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]20
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]1
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID ROY H
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]ROY REID BUILDING COMPANY
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 86, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 52, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 35, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOODLAND TRAILS
[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]13
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]2
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID WILMA L
[/TD]
[TD="class: xl63, width: 256, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, width: 86, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 52, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 35, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOODLAND TRAILS
[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]45
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]1
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 256, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl64, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl64, width: 52, bgcolor: transparent"]1589
[/TD]
[TD="class: xl64, width: 35, bgcolor: transparent"]583
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID ROY
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]PUBLIC
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 86, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 52, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 35, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID WILMA L
[/TD]
[TD="class: xl63, width: 256, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl64, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl64, width: 52, bgcolor: transparent"]1589
[/TD]
[TD="class: xl64, width: 35, bgcolor: transparent"]771
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]J M ATER ADDITION 1
[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]1
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]6
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]SHERMAN BILL
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID BILL
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 86, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 52, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 35, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]J M ATER ADDITION 1
[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]3
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]6
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 256, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl64, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl64, width: 52, bgcolor: transparent"]1595
[/TD]
[TD="class: xl64, width: 35, bgcolor: transparent"]772
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOODLAND TRAILS
[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]15
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]3
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID ROY H
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOOFTER JOSEPH E
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 86, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 52, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 35, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID WILMA L
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOOFTER PATRICIA M
[/TD]
[/TR]
[TR]
[TD="class: xl64, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl64, width: 52, bgcolor: transparent"]1595
[/TD]
[TD="class: xl64, width: 35, bgcolor: transparent"]863
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]WOODLAND TRAILS
[/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"]15
[/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"]3
[/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]CENTRAL TEXAS SAVINGS AND LOAN ASSOCIATION
[/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID ROY H
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 86, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 52, bgcolor: transparent"][/TD]
[TD="class: xl63, width: 35, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 29, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 39, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 256, bgcolor: transparent"]REID WILMA L
[/TD]
[/TR]
</tbody>[/TABLE]


AFTER:

[TABLE="width: 1024"]
<tbody>[TR]
[TD="class: xl71, width: 86, bgcolor: #D6DCE4"]Book Type
[/TD]
[TD="class: xl71, width: 52, bgcolor: #D6DCE4"]Volume
[/TD]
[TD="class: xl71, width: 35, bgcolor: #D6DCE4"]Page
[/TD]
[TD="class: xl71, width: 256, bgcolor: #D6DCE4"]Subdivision
[/TD]
[TD="class: xl71, width: 29, bgcolor: #D6DCE4"]Lot
[/TD]
[TD="class: xl71, width: 39, bgcolor: #D6DCE4"]Block
[/TD]
[TD="class: xl71, width: 50, bgcolor: #D6DCE4"]Section
[/TD]
[TD="class: xl71, width: 152, bgcolor: #D6DCE4"]Survey
[/TD]
[TD="class: xl71, width: 53, bgcolor: #D6DCE4"]Abs No.
[/TD]
[TD="class: xl71, width: 256, bgcolor: #D6DCE4"]Grantor
[/TD]
[TD="class: xl71, width: 256, bgcolor: #D6DCE4"]Grantee
[/TD]
[TD="class: xl71, width: 100, bgcolor: #D6DCE4"]Document Type
[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl65, width: 52, bgcolor: transparent"]1586
[/TD]
[TD="class: xl65, width: 35, bgcolor: transparent"]7
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]WOODLAND TRAILS

[/TD]
[TD="class: xl65, width: 29, bgcolor: transparent"]4
[/TD]
[TD="class: xl65, width: 39, bgcolor: transparent"]3
[/TD]
[TD="class: xl65, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]REID ROY H
REID WILMA L

[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]ROY REID BUILDING COMPANY
[/TD]
[TD="class: xl65, width: 100, bgcolor: transparent"]WD
[/TD]
[/TR]
[TR]
[/TR]
[TR]
[TD="class: xl65, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl65, width: 52, bgcolor: transparent"]1589
[/TD]
[TD="class: xl65, width: 35, bgcolor: transparent"]581
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]WOODLAND TRAILS
WOODLAND TRAILS
WOODLAND TRAILS

[/TD]
[TD="class: xl65, width: 29, bgcolor: transparent"]20
13
45

[/TD]
[TD="class: xl65, width: 39, bgcolor: transparent"]1
2
1

[/TD]
[TD="class: xl65, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]REID ROY H
REID WILMA L

[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]ROY REID BUILDING COMPANY
[/TD]
[TD="class: xl65, width: 100, bgcolor: transparent"]WD
[/TD]
[/TR]
[TR]
[/TR]
[TR]
[/TR]
[TR]
[TD="class: xl65, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl65, width: 52, bgcolor: transparent"]1589
[/TD]
[TD="class: xl65, width: 35, bgcolor: transparent"]583
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 29, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 39, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]REID ROY
REID WILMA L

[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]PUBLIC
[/TD]
[TD="class: xl65, width: 100, bgcolor: transparent"]RESO
[/TD]
[/TR]
[TR]
[/TR]
[TR]
[TD="class: xl65, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl65, width: 52, bgcolor: transparent"]1589
[/TD]
[TD="class: xl65, width: 35, bgcolor: transparent"]771
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]J M ATER ADDITION 1
J M ATER ADDITION 1

[/TD]
[TD="class: xl65, width: 29, bgcolor: transparent"]1
3

[/TD]
[TD="class: xl65, width: 39, bgcolor: transparent"]6
6

[/TD]
[TD="class: xl65, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]SHERMAN BILL
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]REID BILL
[/TD]
[TD="class: xl65, width: 100, bgcolor: transparent"]QCD
[/TD]
[/TR]
[TR]
[/TR]
[TR]
[TD="class: xl65, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl65, width: 52, bgcolor: transparent"]1595
[/TD]
[TD="class: xl65, width: 35, bgcolor: transparent"]772
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]WOODLAND TRAILS
[/TD]
[TD="class: xl65, width: 29, bgcolor: transparent"]15
[/TD]
[TD="class: xl65, width: 39, bgcolor: transparent"]3
[/TD]
[TD="class: xl65, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]REID ROY H
REID WILMA L

[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]WOOFTER JOSEPH E
WOOFTER PATRICIA M

[/TD]
[TD="class: xl65, width: 100, bgcolor: transparent"]WDVL
[/TD]
[/TR]
[TR]
[/TR]
[TR]
[TD="class: xl65, width: 86, bgcolor: transparent"]Deed Record
[/TD]
[TD="class: xl65, width: 52, bgcolor: transparent"]1595
[/TD]
[TD="class: xl65, width: 35, bgcolor: transparent"]863
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]WOODLAND TRAILS
[/TD]
[TD="class: xl65, width: 29, bgcolor: transparent"]15
[/TD]
[TD="class: xl65, width: 39, bgcolor: transparent"]3
[/TD]
[TD="class: xl65, width: 50, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 152, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 53, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]CENTRAL TEXAS SAVINGS AND LOAN ASSOCIATION
[/TD]
[TD="class: xl65, width: 256, bgcolor: transparent"]REID ROY H
REID WILMA L

[/TD]
[TD="class: xl65, width: 100, bgcolor: transparent"]ROL
[/TD]
[/TR]
[TR]
[/TR]
</tbody>[/TABLE]


I am able to do this using an Add-in from John Walkenbach's PUP v7.2 but have to select the rows. I have added the code to the Quick Access menu but it's still a lot of highlighting and clicking. I'm still too new to VBA to even know where to begin. I'm hoping there's a solution to this issue.

Thanks in advance.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top