Conditional Format Result - Get Fill Colour

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,600
Office Version
  1. 365
Platform
  1. Windows
Is there a way of establishing the colour of a cell after conditional formatting has been applied?

The following returns the default or non CF set fill color
VBA Code:
cell.Interior.Color

The cells have no fill but the CF applied will return Red, Amber or Green but I can't find the correct way to establish this.


Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Maybe:
VBA Code:
cell.DisplayFormat.Interior.Color
 
Upvote 0
What is the rest of your code?
 
Upvote 0
What is the rest of your code?
VBA Code:
Function RAGCheck(cell As Range)

RAGCheck = ???
    
End Function

The cell contains the following formula
Excel Formula:
=RAGCheck(B6)
 
Upvote 0
Is that all your code?
 
Upvote 0
The below line does not seem to be supported inside a function:
VBA Code:
cell.DisplayFormat.Interior.Color

A possible workaround could be to have a variable set outside of the function to then call back:
VBA Code:
Dim rCol As Long
Function RAGCheck(cell As Range)
    rCol = cell.Interior.Color
    RAGCheck = rCol
End Function
 
Upvote 0
You cannot use DisplayFormat in a UDF called from a cell.
 
Upvote 0
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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