# Solved: Excel: Formula to check cell color highlight?



## Zenoxio (Jul 18, 2006)

What can I use (formula, etc) to check if a cell has a fill color or not? I have thousands of records with some with a yellow fill color. I need to move those that are filled to another sheet.


----------



## bomb #21 (Jul 1, 2005)

Try this UDF.


----------



## Zenoxio (Jul 18, 2006)

Okay I tried that and the code gives me an error:

```
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Syntax error
---------------------------
OK   Help   
---------------------------
```
at this:

```
If ColorName = True Or _

        strColor = "Custom color or no fill" Then

        CellColor = strColor

    Else

        CellColor = iIndexNum

    End If
```
it highlights the first line


----------



## jimr381 (Jul 20, 2007)

What version of Excel are you using? In 2007 you can sort by color.


----------



## bomb #21 (Jul 1, 2005)

Edit those 2 lines to 1:

If ColorName = True Or strColor = "Custom color or no fill" Then


----------



## Zenoxio (Jul 18, 2006)

Thanks. Either solution worked for me.


----------



## jimr381 (Jul 20, 2007)

Good to hear feel free to post if you have further questions.


----------

