Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to develop a way to return a value if a cell or row is a specific
color. Can anyone let me know if there is a way to write an IF formula that will accomplish this, or do I need to write VBA code (of which it has been years since I've remotely played with.) Thanks for any help! Pam |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You need VBA
Function ColorIndex(rng as range) if rng.Count 1 Then ColorIndex = CVErr(xlErrRef) Else ColorIndex = rng.Interior.Colorindex End If End Function To create this, go to the VBIDE, Alt-F11, menu InsertModule, and copy the code. Back in Excel, use like =IF(Colorindex(A1)=3,"Red","") -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Pam" wrote in message ... I'm trying to develop a way to return a value if a cell or row is a specific color. Can anyone let me know if there is a way to write an IF formula that will accomplish this, or do I need to write VBA code (of which it has been years since I've remotely played with.) Thanks for any help! Pam |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob -
Unfortunately I may be missing something. I'm getting compile errors with this code. Any thoughts I might want to check into? Thanks again!!! "Bob Phillips" wrote: You need VBA Function ColorIndex(rng as range) if rng.Count 1 Then ColorIndex = CVErr(xlErrRef) Else ColorIndex = rng.Interior.Colorindex End If End Function To create this, go to the VBIDE, Alt-F11, menu InsertModule, and copy the code. Back in Excel, use like =IF(Colorindex(A1)=3,"Red","") -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Pam" wrote in message ... I'm trying to develop a way to return a value if a cell or row is a specific color. Can anyone let me know if there is a way to write an IF formula that will accomplish this, or do I need to write VBA code (of which it has been years since I've remotely played with.) Thanks for any help! Pam |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Pam,
Bob's function worked for me. Did you copy / paste Bob's code in order to eliminate possible transcription errors? What errors are you getting and which code line is highlighted? --- Regards, Norman "Pam" wrote in message ... Thanks Bob - Unfortunately I may be missing something. I'm getting compile errors with this code. Any thoughts I might want to check into? Thanks again!!! "Bob Phillips" wrote: You need VBA Function ColorIndex(rng as range) if rng.Count 1 Then ColorIndex = CVErr(xlErrRef) Else ColorIndex = rng.Interior.Colorindex End If End Function To create this, go to the VBIDE, Alt-F11, menu InsertModule, and copy the code. Back in Excel, use like =IF(Colorindex(A1)=3,"Red","") -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Pam" wrote in message ... I'm trying to develop a way to return a value if a cell or row is a specific color. Can anyone let me know if there is a way to write an IF formula that will accomplish this, or do I need to write VBA code (of which it has been years since I've remotely played with.) Thanks for any help! Pam |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
bob's works ok here.
here's sample vba code if you want to try it Sub test() Range("a1").Interior.ColorIndex = 3 If Range("A1").Interior.ColorIndex = 3 Then ActiveCell.Value = "red" End If End Sub -- Gary "Pam" wrote in message ... Thanks Bob - Unfortunately I may be missing something. I'm getting compile errors with this code. Any thoughts I might want to check into? Thanks again!!! "Bob Phillips" wrote: You need VBA Function ColorIndex(rng as range) if rng.Count 1 Then ColorIndex = CVErr(xlErrRef) Else ColorIndex = rng.Interior.Colorindex End If End Function To create this, go to the VBIDE, Alt-F11, menu InsertModule, and copy the code. Back in Excel, use like =IF(Colorindex(A1)=3,"Red","") -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Pam" wrote in message ... I'm trying to develop a way to return a value if a cell or row is a specific color. Can anyone let me know if there is a way to write an IF formula that will accomplish this, or do I need to write VBA code (of which it has been years since I've remotely played with.) Thanks for any help! Pam |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Used drawing colors in shapes....lost default colors for "Fill Col | Excel Discussion (Misc queries) | |||
Cell fill colors don't appear to work... | Excel Discussion (Misc queries) | |||
Excel: is there a way I can lighten the fill colors in a cell? | Excel Discussion (Misc queries) | |||
Can't format font colors or cell fill-in colors | Excel Discussion (Misc queries) | |||
How do I fill row colors based on cell value? | Excel Discussion (Misc queries) |