Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do i give differect color for validation list? | Excel Discussion (Misc queries) | |||
how give excel cell red color if value above range? | Excel Discussion (Misc queries) | |||
Give RELEVANT responses to questions. DO NOT give usless list | Excel Worksheet Functions | |||
How to give function by cell color to sum two value in Excel | Excel Worksheet Functions | |||
formula from multiple worksheets to give a color output to one wo. | Excel Worksheet Functions |