SOLVED

How to have a cell follow a formula ONLY if the cell it's mapping to is a certain colour?

%3CLINGO-SUB%20id%3D%22lingo-sub-1364022%22%20slang%3D%22en-US%22%3EHow%20to%20have%20a%20cell%20follow%20a%20formula%20ONLY%20if%20the%20cell%20it's%20mapping%20to%20is%20a%20certain%20colour%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1364022%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20not%20sure%20if%20it's%20possible%20and%20I%20don't%20have%20a%20screen%20shot%20(I'm%20on%20a%20computer%20that%20doesn't%20have%20excel%20atm)%20but%20I'll%20try%20my%20best%20to%20explain%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EI%20have%20a%20formula%20in%20A1%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DB2%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20I%20only%20want%20A1%20to%20equal%20B2%20if%20B2%20is%20shaded%20yellow.%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20this%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1364022%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1364509%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20have%20a%20cell%20follow%20a%20formula%20ONLY%20if%20the%20cell%20it's%20mapping%20to%20is%20a%20certain%20colour%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1364509%22%20slang%3D%22en-US%22%3E%3CP%3EYeah%20you%20can%20do%20it%20but%20you%20need%20to%20be%20tricky%20for%20this%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirst%20read%20this%20article%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fexcelsirji.com%2Fvba-code-to-count-cells-by-color%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fexcelsirji.com%2Fvba-code-to-count-cells-by-color%2F%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUse%20second%20code%20given%20on%20this%20link%20and%20then%20use%20if%20formula%3C%2FP%3E%3CP%3EPut%20the%20Yellow%20color%20on%20A2%20(or%20anywhere%20just%20change%20the%20reference%20in%20below%20formula%20then)%20cell%20and%20enter%20this%20formula%20in%20A1%3C%2FP%3E%3CP%3E%3Dif(%3CSPAN%3ECountByColor(B2%2CA2)%26gt%3B0%2CB2%2C0)%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1401088%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20have%20a%20cell%20follow%20a%20formula%20ONLY%20if%20the%20cell%20it's%20mapping%20to%20is%20a%20certain%20colour%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1401088%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F476378%22%20target%3D%22_blank%22%3E%40jukapil%3C%2FA%3E%26nbsp%3Bgreat%20answer!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I'm not sure if it's possible and I don't have a screen shot (I'm on a computer that doesn't have excel atm) but I'll try my best to explain:

I have a formula in A1:

=B2

 

However, I only want A1 to equal B2 if B2 is shaded yellow. 

Is this possible?

 

Thanks in advance!

2 Replies
Highlighted
Best Response confirmed by HeatherFX (New Contributor)
Solution

Yeah you can do it but you need to be tricky for this

 

First read this article https://excelsirji.com/vba-code-to-count-cells-by-color/ 

 

Use second code given on this link and then use if formula

Put the Yellow color on A2 (or anywhere just change the reference in below formula then) cell and enter this formula in A1

=if(CountByColor(B2,A2)>0,B2,0)

Highlighted