UDF not updating

mmenofy

New Member
Joined
Apr 30, 2019
Messages
23
Hello,

I've the following UDF but it's not auto updating

Function GetFillColor(Rng As Range) As Long
GetFillColor = Rng.Interior.ColorIndex
End Function

I tried (Application.Volatile) and most of the solution found on internet but nothing changed, Any way to solve it??
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Show me an example of how you are calling it.
 
Upvote 0
Seems to be working for me.
VBA Code:
Function GetFillColor(Rng As Range) As Long
GetFillColor = Rng.Interior.ColorIndex
End Function

Sub FillColor()
MsgBox "The fill color of the Selected cell is " & GetFillColor(Selection) & ".", vbOKOnly, "Fill Color"
End Sub
 
Upvote 0
It seems to work for me. I don't think that you can use a Formula to change cell Format. Maybe use Conditional Formatting instead?
Book1
AB
1G6
Sheet1
Cell Formulas
RangeFormula
B1B1=IF(A1="","",GetFillColor(A1))
 
Upvote 0
Is your colour being changed using Conditional Formatting by any chance ?
If it is try the solution provided here by @Jaafar Tribak

PS: Just change Color to ColorIndex
 
Upvote 0
the formula is only to get the color code (to be used in other cells), i just have legend of colors and want to determine the color code of the cell to be used in other thread
 
Upvote 0
Changing a cell's fill colour does not trigger a recalculation, even if your function is volatile. IMO any attempt to use colours as actual data is flawed.
 
Upvote 0
I noticed that changing colors aren't considered as change in the workbook
I added a button to force calculate the sheet and it worked for me

Thank you so much :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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