Group by SSN?

sandersen

New Member
Joined
Jun 1, 2010
Messages
37
Anyone, I have a large spreadsheet of SSN's in Column A where some SSN's are in multiple rows. I have sorted by SSN but now I would like to have the Rows Grouped and Outlined by the SSN's in Column A. I would like use a MACRO to complete this task. Please help if you can. Thanks again in advance.
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,526
If you have a group of say 3 SSN's together, which of the 3 would you want demoted?
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,526
It'd be something like this:
Code:
   For Each c In Range("A2", Range("A65536").End(xlUp))
        If c.Value = c.Offset(-1, 0).Value Then
            c.EntireRow.Group
        End If
    Next
 

sandersen

New Member
Joined
Jun 1, 2010
Messages
37

ADVERTISEMENT

That work perfectly thanks! I have one more request if you don't mind. Is there a way to highlight every other group a color?
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,526
You could use conditional formatting ... like this ... condition of formula is:

=MOD(ROUND(SUM(1/COUNTIF($A$2:A2,$A$2:A2)),0),2)=1

assuming that the selected region starts in cell A2. Adjust all references ( but maintain the pattern of the $ signs ) if you are selecting a different area for your formatting.
 

sandersen

New Member
Joined
Jun 1, 2010
Messages
37

ADVERTISEMENT

Again that works great, one last question and I will call this one good. I am having difficulty manipulating that last formula to highlight everyother field when the range of data I have is in columns A thru Z. Any suggestions?
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,526
Select A2:Z999 ( or whatever ), and use this formula:

=MOD(ROUND(SUM(1/COUNTIF($A$2:$A2,$A$2:$A2)),0),2)=1
 

Watch MrExcel Video

Forum statistics

Threads
1,122,672
Messages
5,597,488
Members
414,146
Latest member
marginmakerb

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
Top