Hello everyone,
I am looking for a VBA script to restrict which cell fill colours can be used. For example only 6 (pre-chosen) colours are available to the user on 1 particular workbook across all worksheets.
As I am currently using a custom VBA formula that counts cell fill colours and users keep using different shades of said colours and therefore the formula does not count all the relevant cells. Custom formula below...
Function CountColorIf(rSample As Range, rArea As Range) As Long
Application.Volatile
Dim rAreaCell As Range
Dim lMatchColor As Long
Dim lCounter As Long
lMatchColor = rSample.Interior.Color
For Each rAreaCell In rArea
If rAreaCell.Interior.Color = lMatchColor Then
lCounter = lCounter + 1
End If
Next rAreaCell
CountColorIf = lCounter
End Function
Bookmarks