VBA if function based on colors

lcaindoy

New Member
Joined
Jun 12, 2018
Messages
22
Hope you could help me.

I saw the below code in the internet, however, I don't know why it's not working for me.

Function CheckColor1(range)
If range.Interior.Color = RGB(256, 256, 0) Then
CheckColor1 = "***"
Else
CheckColor1 = ""
End If
End Function

Inputs:
1. I have set of data and one column (Let's say J column) has blank, yellow, and other colors in a set of range (J7 to J500)
2. I have tried the above formula but its not working.

Output:
1. Based on the color on each cell, I want to make a markings.
If yellow, it will note "***"
If other, it will be blank
2. output is on column K

Please let me know if you need further info.
 
Last edited:
To me, it looks like it should work as it is. You would use it like:

=CheckColor1(A1)

and if A1 is yellow (again, assuming 256, 256, 0 is yellow) it should put "***" in the cell the formula is in, which I would assume would be B1.

It's still not working, I've tried doing it on a new file like nothing is there. It is still not working.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I put EXACTLY what you have in a standard (not worksheet, not workbook) code module and in the same workbook, I used it like this:


Book1
AB
1***
2
3***
4
5***
Sheet1
Cell Formulas
RangeFormula
B1=checkcolor1(A1)


and that's what I got.
 
Upvote 0

Forum statistics

Threads
1,221,526
Messages
6,160,340
Members
451,637
Latest member
hvp2262

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