VBA merge cells that contain the same value but within a particular group

sm786

New Member
Joined
Mar 21, 2013
Messages
2
Hi All,

I have a question regarding automatic merging in VBA. Its similar to this thread (http://www.mrexcel.com/forum/excel-...tically-merge-vertically-identical-cells.html) but with a slight twist.

So say if I have four columns set up as follows, where the first line contains headings (before)

TeamPositionSalaryTerm (years)
ArsenalGoalkeeper1001
ArsenalGoalkeeper1001
ArsenalGoalkeeper502
ArsenalMidfield502
ArsenalMidfield502
ArsenalStriker252
ManchesterStriker252
ManchesterStriker253
ManchesterStriker253
ManchesterManager251
ManchesterManager251
ManchesterManager301
ChelseaManager352
ChelseaStaff352
ChelseaDefender252
ChelseaDefender252
ChelseaStriker252
ChelseaStriker252

<col width=80 style='mso-width-source:userset;mso-width-alt:2925;width:60pt'> <col width=79 style='mso-width-source:userset;mso-width-alt:2889;width:59pt'> <col width=44 style='mso-width-source:userset;mso-width-alt:1609;width:33pt'> <col width=85 style='mso-width-source:userset;mso-width-alt:3108;width:64pt'>
<![if supportMisalignedColumns]>
<![endif]>


Im looking for something like this (please ignore the periods as i had to put them to keep the table from incorrectly displaying).
I'd like to highlight the non-merging of Striker (line 7 and 8 in column2) becasue one belongs to Manchester and the other to Arsenal
TeamPositionSalaryTerm (years)
ArsenalGoalkeeper1001
....
..502
.Midfield502
....
.Striker252
ManchesterStriker252
...3
....
.Manager251
....
..301
ChelseaManager352
.Staff352
.Defender252
....
.Striker252
....

<col width=64 span=4 style='width:48pt'> <col class=xl6522403 width=64 style='width:48pt'>
<![if supportMisalignedColumns]>
<![endif]>
</div>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Have you tried a pivot table? Here's on I created in Excel 2010:


Excel 2010
KLMN
1TeamPositionSalaryTerm (years)
2ArsenalGoalkeeper502
31001
4Midfield502
5Striker252
6ChelseaDefender252
7Manager352
8Staff352
9Striker252
10ManchesterManager251
11301
12Striker252
133
Sheet1
 
Upvote 0
thank you for your quick response!Unfortunately I dont think that will work as there are other columns to the right of the four that are all text which dont need to be considered for merging...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,323
Members
449,077
Latest member
jmsotelo

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