Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default A formula to type 1 in B2 if A2 has the color green?

Is there a way to make a formula that recognizes the cell color like if A2 is
green, then my formula in B2 would recognize this color and return the value
1, then 0 for yellow and -1 for red for example. - a form of reverse
conditional formatting.

If not, how to to this in vba?

Rgds
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default A formula to type 1 in B2 if A2 has the color green?

There's nothing built into excel that does this.

But you can use a UDF that looks at cells and returns the color. But that
function won't recalculate if you change color. You won't be able to trust the
output until excel recalculates.

If you want to use a UDF like this, you can visit Chip Pearson's site:
http://www.cpearson.com/Excel/colors.aspx



Henrik wrote:

Is there a way to make a formula that recognizes the cell color like if A2 is
green, then my formula in B2 would recognize this color and return the value
1, then 0 for yellow and -1 for red for example. - a form of reverse
conditional formatting.

If not, how to to this in vba?

Rgds


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default A formula to type 1 in B2 if A2 has the color green?

Try the below UDF; will return the color index of a cell

=GetColorIndex(A1)
will return 0 if not filled. Now you can combine this with IF formula to
suit your requirement.

Function GetColorIndex(varRange)
GetColorIndex = varRange.Interior.ColorIndex
If GetColorIndex = -4142 Then GetColorIndex = 0
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Henrik" wrote:

Is there a way to make a formula that recognizes the cell color like if A2 is
green, then my formula in B2 would recognize this color and return the value
1, then 0 for yellow and -1 for red for example. - a form of reverse
conditional formatting.

If not, how to to this in vba?

Rgds

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the color in a chart, so POSITIVE values is e.g. GREEN and MIKE-DENMARK Charts and Charting in Excel 2 October 10th 07 12:22 PM
Change a cell color based on a certain value (green or red) Ugbe Excel Worksheet Functions 2 May 23rd 06 12:22 PM
conditional formatting COLOR - pale green LTUser54 Excel Discussion (Misc queries) 2 May 19th 06 03:37 PM
I want the bar chart with customer selected colors, green color f. junminliu Charts and Charting in Excel 2 March 20th 05 03:12 PM
Format color - darker green available? DrB Excel Worksheet Functions 4 February 10th 05 05:53 AM


All times are GMT +1. The time now is 04:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"