Code help

M

MAX

Hello
I need a code for Range("C4").value. This must be equal to:

1. When font colour in B3 and E3 is black, value= HORSE
2. When font colour in B3 or E3 is blue, value = Range B3 or E3.
I don't know if it is possible, any help?

Thanks in advance.
 
R

Rick Rothstein

Your specification is not very clear. I assume Condition #2 means if B3 is
blue, then assign B3's value to C3 or if E3 is blue, then assign E3's value
to C3; but what if both C3 and E3 are blue... what assignment should be made
then? Also, what if one of either B3 E3 are blue and the other is black...
what assignment should be made in that case? Finally, what did you want
assigned to C4 if none of those conditions are met?
 
J

JLatham

Trying to do things based on color is really a generally bad idea. How are
the font colors in B3/E3 getting set to Black or Blue? If you're using
conditional formatting for them to change color, then use the same rule you
used for conditional formatting to set the value of C4.
And what do we do if both B3 and E3 have blue font? Which value to choose
then?

But if you really want code to get the job done, it's probably going to be
Worksheet_Change() or Worksheet_Activate() event code, and we need a complete
set of rules to create the code from. So far we have
B3 AND E3 are black font, C4="HORSE"
but actually beyond that, no set rules:
B3 AND E3 are blue -- do what with C4
B3 is blue, E3 is black -- do what with C4 (set = B3 I think?)
B3 is black, E3 is blue -- do what with C4 (set =E3 I think?)

By the way, if B3 and E3 font color is being set to Blue (or black) via
conditional formatting, it becomes very difficult to test the font color as
it will show as the basic non-conditional formatted color, so we would need
to know the rules applied to B3 and E3 for the conditional formatting to
write the code -- which leads us back to simply applying the same rules to C4
without using any code at all.
 
M

MAX

Hello Rick
I used conditional formatting for these to change colours.
If I have C3 = D3, B3 and E3 remain black.
IF I have C3 > D3 the font colour in B3 becomes blue and E3 becomes red and
vice versa.
So when B3 is black, E3 is always black and vice versa.
When B3 is blue, E3 becomes red and vice versa.
Is this helps you?

Thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top