I want to check data tables over several years to find specially colored cells.
People have not always chosen the same color of cells for many years (they can all be the same for the human eye, but have different RGB values).
If I have a cell with an RGB interior color (255,23,50), is there a way to create a color vector to see if the color of the inside of the cell falls on it? I am trying to create a vector with +/- 15 RGB dots, so if I look for cells with RGB (255,23,50), I want a vector between RGB (255,38,65) and RGB (240,8, 35).
I could use the IF statement to see if the color is between these two values, but I could use the color vector for more applications (and the code would be easier to change if it needed to be changed).
This is if the expression works:
If ActiveWorkbook.Worksheets("Sheet1").Range("e5").Interior.Color >= RGB(240, 8, 35) And ActiveWorkbook.Worksheets("Sheet1").Range("e5").Interior.Color <= RGB(255, 38, 65) Then
MsgBox ("yes")
Else
MsgBox ("no")
End If
I am looking for something more like:
dim redVector as long ' or other appropriate variable type
' ***** code that defines the red vector *****
if range("e5").interior.color = redVector then
' do stuff
end if
source
share