Banding like parts

Jeffrey Green

Well-known Member
Joined
Oct 24, 2007
Messages
1,021
I have 4000 rows with hundreds of unique Part numbers. My list is sorted by Part Number.

I might have 1 Part number, I might have 5 the same, I might have 200 the same.

I would like to conditionally format the rows so Like parts are banded together. Blue/White (no formatting) would be fine . . .I just need a visual clue that the part number changed.

Too many to do by hand


Thoughts??
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
With sample data in Sheet1, like so.. Highlight the Range(A4:A16) and Run Code below..
Excel Workbook
A
1
2
3PartNumber
4ABC
5ABC
6ABC
7DDD
8EEE
9FFF
10FFF
11FFF
12FFF
13GG
14HH
15HH
16HH
Sheet1
Excel 2007

Code:
Sub ShadeLikeItems()
Dim Rng As Range
Dim OldVal As Variant
Dim Yellow As Boolean

Yellow = True
OldVal = Null
For Each Rng In Selection ' CHANGE TO CORRECT RANGE
    If Rng.Value = OldVal Then
        If Yellow Then
            Rng.Resize(1, 6).Interior.ColorIndex = 6   'Change to suit
        Else
            Rng.Resize(1, 6).Interior.ColorIndex = -4142
        End If
    Else
        OldVal = Rng.Value
        Yellow = Not Yellow
        If Yellow Then
            Rng.Resize(1, 6).Interior.ColorIndex = 6    'change to suit
        Else
            Rng.Resize(1, 6).Interior.ColorIndex = -4142
        End If
    End If
Next Rng
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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