Solved

Excel -- need formula based on cell color

Posted on 2013-11-02
5
721 Views
Last Modified: 2013-11-02
Experts:

I'm using  a module that scans for certain patterns across thousand of rows.

If a pattern is found, the macro applies a cell background color = yellow to each record (columns A:X) .

For another activity, I now would like to use a formula to identify those records.  For example:

=If(A1=Yellow,"Error","Ok")   How can this be accomplished?

Thanks,
EEH
0
Comment
Question by:ExpExchHelp
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:CompProbSolv
ID: 39618905
0
 

Author Comment

by:ExpExchHelp
ID: 39618920
Not sure if those posts address what I'm looking for.

Probably my fault for not further elaborating.

If a cell (A1) color is yellow, I'd like to display in AB1 either "Yellow" or "X" or anything that can be used by another formula to differentiate between white and yellow cells.

Thanks,
EEH
0
 
LVL 20

Accepted Solution

by:
CompProbSolv earned 500 total points
ID: 39618930
Those links refer to using VBA and not a cell formula.  This one will show you how to create such a function:
http://en.kioskea.net/faq/6606-excel-formula-based-on-the-color-of-cell

The fourth post here may be helpful:
http://www.ozgrid.com/forum/showthread.php?t=82173

I think that creating the function is a better solution.
0
 

Author Closing Comment

by:ExpExchHelp
ID: 39618936
Thanks... that did the trick.  ;)
0
 
LVL 20

Expert Comment

by:CompProbSolv
ID: 39618963
I played with this a bit and came up with the following function:

Public Function dispColorIndex(targetCell As Range) As Variant

    dispColorIndex = targetCell.Interior.colorIndex
           
End Function

For your situation, put the following in B1:
=dispColorIndex(A1)

Do note that the formula does not automatically update.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question