Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Give a value to the color of a cell

Hi, I am trying to use a conditional to get a value from another cell. i.e.

A1 background color is yellow. in B1 I would write something like
if(A1=yellow,1,0) to get a value 1 in the cell B1, or 2 for blue, etc...

Thank you for your help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Give a value to the color of a cell

Hi,

You can do it with a UDF.
Alt +F11 to open VB editor. Right click 'This Workbook' and insert module
and paste the code below in. The code is easy to update to addd extra colours
and if you not sure what the numbers are record a macro of yourself colouring
cells and use the numbers to add additional cases.

Call with
=BackColour(A1)


Function BackColour(r As Range)
Select Case r.Interior.ColorIndex
Case Is = 6 'Yellow
BackColour = 1
Case Is = 5 'Blue
BackColour = 2
Case Is = 4 'Green
BackColour = 3
Case Is = 3 'red
BackColour = 4
Case Is = 53 'Brown
BackColour = 5
Case Else
BackColour = "Not Defined"
End Select
End Function


"Sebastian" wrote:

Hi, I am trying to use a conditional to get a value from another cell. i.e.

A1 background color is yellow. in B1 I would write something like
if(A1=yellow,1,0) to get a value 1 in the cell B1, or 2 for blue, etc...

Thank you for your help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Give a value to the color of a cell

How did A1 get to be yellow?

If by Conditional Formatting, use the CF condition as criterion.

If manually colored yellow, you will need VBA function.

See Chip Pearson's site for that.

http://www.cpearson.com/excel/colors.aspx


Gord Dibben MS Excel MVP

On Fri, 14 Nov 2008 01:31:01 -0800, Sebastian
wrote:

Hi, I am trying to use a conditional to get a value from another cell. i.e.

A1 background color is yellow. in B1 I would write something like
if(A1=yellow,1,0) to get a value 1 in the cell B1, or 2 for blue, etc...

Thank you for your help.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Give a value to the color of a cell

I have this same issue. The background color is manually applied. My
example is if cell B6 is yello - I want 1 to populate in E6.

Can you tell me how to do the VBA function to achieve that?

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Give a value to the color of a cell

I'm sure you have a grander plan in mind, but per your example.......

Sub enter_1()
If Range("B6").Interior.ColorIndex = 6 Then
Range("E6").Value = 1
End If
End Sub

Post back with the rest of the details for a more complete reply.


Gord Dibben MS Excel MVP


On Fri, 6 Feb 2009 07:34:08 -0800, Cassie <Cassie
wrote:

I have this same issue. The background color is manually applied. My
example is if cell B6 is yello - I want 1 to populate in E6.

Can you tell me how to do the VBA function to achieve that?

Thanks




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
how do i give differect color for validation list? imratish Excel Discussion (Misc queries) 2 November 19th 07 07:57 AM
how give excel cell red color if value above range? Julien Excel Discussion (Misc queries) 2 September 28th 06 02:18 PM
Give RELEVANT responses to questions. DO NOT give usless list pmartin Excel Worksheet Functions 2 July 6th 06 06:08 PM
How to give function by cell color to sum two value in Excel viraj Excel Worksheet Functions 4 April 28th 06 09:59 AM
formula from multiple worksheets to give a color output to one wo. vikingshooter Excel Worksheet Functions 0 February 10th 05 03:19 PM


All times are GMT +1. The time now is 02:35 PM.

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

About Us

"It's about Microsoft Excel"