Excel formatting query
Author
Discussion

davidkerr1482

Original Poster:

1 posts

131 months

Thursday 25th January 2018
quotequote all
Hi folks,

I currently have an excel problem I need to solve at work involving conditional formatting.let me explain.

I have the values, 2D, 2C,2S,3D,3C and 3S. This is the correct order of importance from lowest to highest in terms of value. I am looking to conditionally format the value in the next adjacent cell if it is higher and lower than the previous cell, ie the cell turns red if 2C is in say cell A1 and 2D is entered into cell A2. And green if a higher value is entered etc.

I can’t get conditional formatting to work properly because the contents of the cell are numbers and text ie 2C and I can’t seem to find a way to tell excel that 2C is greater than 2D and so on. Hopefully someone is reading this that uses excel daily and can help solve my problem!

anonymous-user

86 months

Thursday 25th January 2018
quotequote all
An easy way would be to make a table of the 2C, 2D etc with a value assigned to them that matches their hierarchical value. Then have a vlookup column that gives this value and then a column that use a IF function for the row below being higher/lower, this can then be the basis for a conditional format using the formula function and IF.





Edited by anonymous-user on Thursday 25th January 20:19

ZesPak

26,177 posts

228 months

Thursday 25th January 2018
quotequote all
I would do something like this, split the numbers up, give the letters a value (using column and indirect), then sum up the two, simples:



Result:


So the number are the hundreds, while the decimal and single digits are for the letter (A=1, B=2).

Short version:


=LEFT(D4;1)*100+COLUMN(INDIRECT(RIGHT(D4;1)&1))

Edited by ZesPak on Thursday 25th January 20:04

mikef

6,158 posts

283 months

Thursday 25th January 2018
quotequote all
If that is the entire fixed list of values that you are comparing, you could probably do something in a conditional formatting formula that compares LEFT(cell) in ascending order then RIGHT(CODE(RIGHT(cell))) in descending order, as the ASCII values for D,C,S are 68, 67 and 83 respectively

Very hacky and fragile though

weeboot

1,065 posts

131 months

Friday 26th January 2018
quotequote all
ZesPak said:
I would do something like this, split the numbers up, give the letters a value (using column and indirect), then sum up the two, simples:



Result:


So the number are the hundreds, while the decimal and single digits are for the letter (A=1, B=2).

Short version:


=LEFT(D4;1)*100+COLUMN(INDIRECT(RIGHT(D4;1)&1))

Edited by ZesPak on Thursday 25th January 20:04
Go easy if you're using INDIRECT, as a volatile function it doesn't scale well. Fine in a few instances, but if you've got a couple of hundred rows or more, all running INDIRECT, it can start to have an impact.

ZesPak

26,177 posts

228 months

Friday 26th January 2018
quotequote all
weeboot said:
Go easy if you're using INDIRECT, as a volatile function it doesn't scale well. Fine in a few instances, but if you've got a couple of hundred rows or more, all running INDIRECT, it can start to have an impact.
Pah, scales pretty good on current day machines.
Not nearly as often used as Today() or Now() either, both volatiles as well.