Conditional formatting and IF statements

Solved/Closed
dazzalar1987 - Jul 10, 2012 at 06:10 AM
 Darren - Aug 3, 2012 at 05:07 AM
Hi

Please can someone help with a problem I have encountered on Excel 2003. I am trying to use conditional formatting however I have 4 variables rather than 3.

I have created a spreadsheet to show my top 10 customers satisfaction levels on a monthly basis. I have created the spreadsheet to colour co-ordinate any changes that have happened from the previous month. If the score decreases then the cell will change to red, if the score stays the same then the cell will change to yellow and if the score has increased then it changes to orange. What I now want to do is have something that changes the cell to green if its a score of 100%.

The 3 rules I have in place are useful until I hit a score of 100%. If the previous month the score was 80% and it is now 100% the cell changes to orange as this was an increase from the previous month. If I then try to fill the cell green then I have to delete the 3 rules and then just fill the cell green which defeats the point of having the conditional formatting.

Is an If statement a possible solution? Any help will be greatly appreciated

Darren
Related:

2 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Jul 17, 2012 at 09:11 AM
Hi Darren,

Using more then 3 statements using conditional formatting is a common problem.

Try this link:
https://ccm.net/forum/affich-21716-conditional-formatting-more-than-3-in-excel

Best regards,
Trowa
2
I am unfamiliar with VBA and macros so this will probably be a bit too in depth for me.
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Jul 24, 2012 at 09:05 AM
Hi Darren,

Could you post the formula's you are using in conditional format + the forth one.
Also tell me which cells the conditional format is applied to.

Best regards,
Trowa
0
Hi Trowa

I am not using formulas. I have conditionally formatted a cell so that it changes colours based on the information that I am putting in manually from a previous column. So for example if i manually type into cell A1 82% I have conditionally formatted cell B2 to either change to red if it is below 82%. I have added a second conditional format which if B2 is =82% this will change to yellow as it is the same score and if it is anything above 82% the 3rd condition is to change the cell colour to show orange, The problem I encounter is if the previous score is less than 100% and then I get a score of 100% the cell colour changes to orange as it is an increase. What I want to happen is for any cells that contain 100% to change to green. I will only be using a certain range of cells for 10 customers over a 12 month period. I must admit I would call myself an amateur with Excel and googled if it was possible to add a 4th conditional format on Excel 2003 and this seemed to be the most useful forum out of the lot of them.
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Jul 26, 2012 at 09:42 AM
Hi Darren,

Basically anything with an = in front of your criteria means it is a formula.

So your situation is like:
Conditonal format is applied to B2.
1. =B2<A1    Color Red
2. =B2=A1    Color Yellow
3. =B2>A2    Color Orange
4. =B2=100%  Color Green


To make this work automatically right-click on the sheets tab and select view code.
Paste the following code in the big white field:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then
If Intersect(Target, Range("B2")) Is Nothing Then Exit Sub
End If
If Range("B2").Value < Range("A1").Value Then Range("B2").Interior.ColorIndex = 3
If Range("B2").Value = Range("A1").Value Then Range("B2").Interior.ColorIndex = 6
If Range("B2").Value > Range("A1").Value Then Range("B2").Interior.ColorIndex = 45
If Range("B2").Value = 1 Then Range("B2").Interior.ColorIndex = 10
End Sub


Now change the value in either A1 or B2 and see if the colorcoding works.

PS. I assumed you formatted the cells as Percentage.

Best regards,
Trowa
0
Sorry about all the messages.

I have now removed the conditional formatting and have used the codes you have provided and it works perfectly however I dont know what the colour code is for the lighter shade of green which is the colour I need (lime green). As the colour code you provided was a dark green. I am currently in work and having some network issues so would like to apologise if you are receiving duplicate messages from me

I also have a further question. The code you have provided I implemented it for just one cell to try and use it. I have cells that I need to use from varying areas on the spread sheet

Would I need to write 10 of these codes to allow me to do it for each cell down from the one above or is there a way of doing it to include all the 10 cells

On the sheet I am using I need to use the information to change the cell colour from cell F4 down to F13 from the information that is in cell C4 down to C13.

and also would I need to write 12 seperate codes to allow me to do it for the 12 seperate months or can I use the one code but add all the varying cell ranges

I assumed this would work but its causing problems

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F4:F13")) Is Nothing Then
If Intersect(Target, Range("C4:C13")) Is Nothing Then Exit Sub
End If
If Range("F4:F13").Value < Range("C4:C13").Value Then Range("F4:F13").Interior.ColorIndex = 3
If Range("F4:F13").Value = Range("C4:C13").Value Then Range("F4:F13").Interior.ColorIndex = 6
If Range("F4:F13").Value > Range("C4:C13").Value Then Range("F4:F13").Interior.ColorIndex = 45
If Range("F4:F13").Value = 1 Then Range("F4:F13").Interior.ColorIndex = 10
End Sub
0
Hi Trowa

I have put nothing in the cell with an = sign

I went to the Format tab, Conditional formatting and then just filled in the relevant boxes to allow excel to then change the cell colour based on the information I manually enter on the previous cell.

I would like to apologise if I sound extremely stupid but I really am an amateur with excel

Do I need to remove all of the conditonal formatting I have input to allow the code to work?
0