Bypassing colour limitations of Interior.ColorIndex?

jack2

New Member
Joined
Jul 6, 2018
Messages
8
At the moment, Interior.ColorIndex (if I am correct) has a limitation of 56 colours?

Is there any way I can get around that? As can be seen, after row 55, it doesn't highlight duplicates (The code highlights duplicates if that record has a duplicate)

File: https://www.dropbox.com/s/2k7eqr85oienk2b/colour-cells.xls?dl=0

Code:
Sub different_colour()Dim lrow As Integer
lrow = Worksheets("sheet1").Range("B2").CurrentRegion.Rows.Count - 1 + 2
For N = 3 To lrow
If Application.WorksheetFunction.CountIf(Worksheets("sheet1").Range("B3:B" & lrow), Worksheets("sheet1").Range("B" & N)) = 1 Then
GoTo skip
Else
Worksheets("sheet1").Range("B" & N).Interior.ColorIndex = Application.WorksheetFunction.Match(Worksheets("sheet1").Range("B" & N), Worksheets("sheet1").Range("B3:B" & lrow), 0) + 2
End If
skip: Next N
Worksheets("sheet1").Activate
Range("B3").Select
End Sub

lV1zCJi.png
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try using the color property instead. For example, something like
Code:
Worksheets("sheet1").Range("B" & N).Interior.Color = 1000 + 10000 * Application.WorksheetFunction.Match(Worksheets("sheet1").Range("B" & N), Worksheets("sheet1").Range("B3:B" & lrow), 0)
 
Upvote 0

Forum statistics

Threads
1,223,785
Messages
6,174,540
Members
452,571
Latest member
MarExcelTips

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