Function Not Working with Conditional Formatting

sub80

New Member
Joined
Oct 17, 2020
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hi;

Made a function which checks if the cell color is red or yellow and returns the word or returns nothing"". The sheet with the function looks into another workbook with conditional formatting which turns the cell into three/four colors dependent on the cell input. My issue is that the function does not work with cell coloring by conditional formatting. Works fine with regular cell color placement. How can I get it to see the coloring by the conditional formatting.

Code:
Function Checkcolor(range)
If range.Interior.ColorIndex = 3 Then
Checkcolor = "RED"
ElseIf range.Interior.ColorIndex = 6 Then
Checkcolor = "YELLOW"
Else
Checkcolor = "WHAT"
End If

End Function


Regards;
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
If you are using the function in a cell, you cannot use the DisplayFormat property, so you have to evaluate each of the format conditions.
 
Upvote 0
I've got a really ugly way to do it...

Select the Range (column) of the cells you want to evaluate the color of the conditional formatting and then Run the Macro - ColorofRange

VBA Code:
Sub GetCFcolor()
X = ActiveCell.DisplayFormat.Interior.Color
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = X
End Sub

Sub ColorofRange()
Dim c As Excel.Range
For Each c In Selection
GetCFcolor
ActiveCell.Offset(1, -1).Select
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,977
Messages
6,182,117
Members
453,090
Latest member
boonga

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