Hi there,
I am developing a spreadsheet that uses data validation and a chooser box to
select Y or N and depending upon the result drops a value in the adjacent
box.
This works as expected and depending upon the formula will enter a number
from 1-5 when N is selected from the chooser.
I would like to allocate different colours to result, i.e.
If Y is selected I would like the Y to appear in green in the chooser to
indicate an OK result. In this case there is no value dropped into the
adjacent box when Y is chosen.
If N is selected I would like the N to appear in Red in the chooser and the
result that is dropped in the adjacent box to be coloured accordingly.
For example if 5 is the value then this should be displayed in Red
If a 1 is the result than display this in Cyan etc.
As an example the formula I use to return the result is based upon the
following;
=IF(E19=quot;Nquot;,1,quot;quot;)
Is this possible please?
--
Thanks amp; regards,
-pp-
This should get you started. It assumes the DV box is E5Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range(quot;E5, E19quot;)) Is Nothing Then
If Range(quot;E5quot;).Value = quot;Yquot; Then
Select Case Range(quot;E19quot;).Value
Case 1: Range(quot;E19quot;).Interior.ColorIndex = 1
Case 2: Range(quot;E19quot;).Interior.ColorIndex = 2
Case 3: Range(quot;E19quot;).Interior.ColorIndex = 3
Case 4: Range(quot;E19quot;).Interior.ColorIndex = 4
Case 5: Range(quot;E19quot;).Interior.ColorIndex = 5
Case Else: Range(quot;E19quot;).Interior.ColorIndex = 10
End Select
Else
Select Case Range(quot;E19quot;).Value
Case 1: Range(quot;E19quot;).Interior.ColorIndex = 21
Case 2: Range(quot;E19quot;).Interior.ColorIndex = 22
Case 3: Range(quot;E19quot;).Interior.ColorIndex = 23
Case 4: Range(quot;E19quot;).Interior.ColorIndex = 24
Case 5: Range(quot;E19quot;).Interior.ColorIndex = 8
Case Else: Range(quot;E19quot;).Interior.ColorIndex = 3
End Select
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.
--
HTHBob Phillips
(remove nothere from the email address if mailing direct)
quot;Pheasant Plucker®quot; gt; wrote in message
...
gt; Hi there,
gt;
gt; I am developing a spreadsheet that uses data validation and a chooser box
to
gt; select Y or N and depending upon the result drops a value in the adjacent
gt; box.
gt;
gt; This works as expected and depending upon the formula will enter a number
gt; from 1-5 when N is selected from the chooser.
gt;
gt; I would like to allocate different colours to result, i.e.
gt;
gt; If Y is selected I would like the Y to appear in green in the chooser to
gt; indicate an OK result. In this case there is no value dropped into the
gt; adjacent box when Y is chosen.
gt;
gt; If N is selected I would like the N to appear in Red in the chooser and
the
gt; result that is dropped in the adjacent box to be coloured accordingly.
gt;
gt; For example if 5 is the value then this should be displayed in Red
gt;
gt; If a 1 is the result than display this in Cyan etc.
gt;
gt; As an example the formula I use to return the result is based upon the
gt; following;
gt;
gt; =IF(E19=quot;Nquot;,1,quot;quot;)
gt;
gt; Is this possible please?
gt;
gt; --
gt; Thanks amp; regards,
gt; -pp-
gt;
gt;
If you are not into VBA coding the easiest way to do this is with
conditional formatting.
Ed--
EdMac
------------------------------------------------------------------------
EdMac's Profile: www.excelforum.com/member.php...oamp;userid=30736
View this thread: www.excelforum.com/showthread...hreadid=504334Not with 5 values it's not.
--
HTH
Bob Phillips
(remove nothere from the email address if mailing direct)
quot;EdMacquot; gt; wrote in
message ...
gt;
gt; If you are not into VBA coding the easiest way to do this is with
gt; conditional formatting.
gt;
gt; Ed
gt;
gt;
gt; --
gt; EdMac
gt; ------------------------------------------------------------------------
gt; EdMac's Profile:
www.excelforum.com/member.php...oamp;userid=30736
gt; View this thread: www.excelforum.com/showthread...hreadid=504334
gt;
Agreed,Bob, but not clear exactly what is required.
Ed--
EdMac
------------------------------------------------------------------------
EdMac's Profile: www.excelforum.com/member.php...oamp;userid=30736
View this thread: www.excelforum.com/showthread...hreadid=504334Thanks for the replies Bob amp; Ed,
That first reply from you Bob nearly blew my mind...where on earth does that
lot go?
Conditional formatting sounds like it might be easier - if I were to reduce
the number of colours needed from 5 down to 3 or even 2 how would
conditional formatting work?
An example or two would be nice - please excuse my ignorance and bear with
me - I am a complete idiot when it comes to Excel (and many other things
besides! :-)
Thanks amp; regards,
-=pp=
I did explain at the end how to implement it. If you want CF
Select all the cells, starting at let's say A2
Menu Formatgt;Conditional Formatting
Change Condition 1 to Formula Is
Add formula of =AND(E5=quot;Yquot;,E19=1)
Click Format
Select Pattern tab
Select red
OK
Click Addgt;gt;
Change Condition 1 to Formula Is
Add formula of =AND(E5=quot;Yquot;,E19=2)
Click Format
Select Pattern tab
Select green
OK
OK
obviously change the cells to suit.--
HTH
Bob Phillips
(remove nothere from the email address if mailing direct)
quot;Pheasant Plucker®quot; gt; wrote in message
...
gt; Thanks for the replies Bob amp; Ed,
gt;
gt; That first reply from you Bob nearly blew my mind...where on earth does
that
gt; lot go?
gt;
gt; Conditional formatting sounds like it might be easier - if I were to
reduce
gt; the number of colours needed from 5 down to 3 or even 2 how would
gt; conditional formatting work?
gt;
gt; An example or two would be nice - please excuse my ignorance and bear with
gt; me - I am a complete idiot when it comes to Excel (and many other things
gt; besides! :-)
gt;
gt; Thanks amp; regards,
gt; -=pp=
gt;
gt;
Bob's reply required you to be able to use VBA - that is fairly advanced
stuff.
With Conditional formatting (Formatgt;conditional formatting), you can
set the format according to what is in the cell OR what is in another
cell in the same sheet.
So if you want the the drop down box to be Red if there is 'N0' in it
Condition1 Cell Valuegt;Is equal togt;=quot;Noquot;
Then select format and you gett he chance to select the coulour of the
font, cell infill and border.
Then select 'ADD' and you get the chance to set another format - e.g.
for Yes. Repeat the process.
You can use al the normal Excel rules like IF, AND etc to build up
complicated setups.
Hope this helps
Ed--
EdMac
------------------------------------------------------------------------
EdMac's Profile: www.excelforum.com/member.php...oamp;userid=30736
View this thread: www.excelforum.com/showthread...hreadid=504334
- Dec 25 Tue 2007 20:41
Adding colour to result in a cell?
close
全站熱搜
留言列表
發表留言