I have purely used this to check on cells E19:E20 but is easily altered;
Code:
For i = 19 To 20
If Cells(i, 5).Interior.ColorIndex = 3 Then
Cells(i, 6) = 1
Else
If Cells(i, 5).Interior.ColorIndex = 6 Then
Cells(i, 6) = 2
End If
End If
Next i
the for i is the range of rows you are checking with 19 To 20 being row numbers.
Cells(i , 6) equates to Cells(Row Number , Column Number)
The colurIndex identifys colour, if you record a macro of you colouring cells it will give you a fair idea of what numbers you require for your colour range.
Hi, you have to indicate what you are talking about when you write, "cell color".
Are we talking about the font? Or are we talking about cell shading with regards to pattern: FORMAT/CELL/[PATTERN TAB]
If we are talking about cell shading, then there is no direct Excel function that will allow you to determine the color.
However, creating a custom function is quite easy. Put the following in a module in your worksheet:
Function WhatColor(rngA As Range) As Integer
WhatColor = rngA.Interior.ColorIndex
End Function
Your IF statement on your worksheet would then be =IF(WhatColor(A1)=54,"purple","not purple")
You'll find though that if you change the color of the cell pattern, your spreadsheet will not calculate. Thus the function WhatColor does not update. Even if you declare the function volatile. It will only update when you actually change a value in any cell in the workbook.
This may not fit what you need and you may want to think of an alternative way to do what you want.
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.