# Excel question

**URL:** <https://forums.teamphoenixrising.net/t/excel-question/13729>\
**Category:** Coding and Design\
**Created:** [10 November 2006 14:26 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729 "2006-11-10T14:26:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![PMM](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/p/ad7895/32.png) [@PMM](https://forums.teamphoenixrising.net/u/PMM)\
**Post date:** [10 November 2006 14:26 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/1 "2006-11-10T14:26:17Z")

</div>

I really don’t know if this is do-able or not, I don’t know how best to search  
for what i’m after that provides me usefull info on what avenue to follow.

In short is there a way on saying i.e. if cell XX = value then display value but colour the cell background with colour xx

The idea being importing a CSV file generated by our main Movex system  
then highlighting in block form values that differ from an auto generated base average in a traffic light type system where if the value is x% then colour Green if y% colour Yellow if z% colour red.

---

<div class="post-metadata">

**Author:** ![Damski](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/d/aca169/32.png) [@Damski](https://forums.teamphoenixrising.net/u/Damski)\
**Post date:** [10 November 2006 14:38 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/2 "2006-11-10T14:38:33Z")

</div>

I think what your after is conditional formating, BUT you can only have 3 options for each cell, but it’s doable. I havent got office installed here so I can’t tell you where the option is , sorry.

Damski

---

<div class="post-metadata">

**Author:** ![PMM](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/p/ad7895/32.png) [@PMM](https://forums.teamphoenixrising.net/u/PMM)\
**Post date:** [10 November 2006 15:00 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/3 "2006-11-10T15:00:35Z")

</div>

That’s the one 🙂 looks like it maybe a bit long winded to set up  
but indeed that’s the effect I’m after.

Just maybe a ballache to set each and every cell up to ref the right data.

Thx Damski 👍

---

<div class="post-metadata">

**Author:** ![Damski](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/d/aca169/32.png) [@Damski](https://forums.teamphoenixrising.net/u/Damski)\
**Post date:** [10 November 2006 17:07 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/4 "2006-11-10T17:07:31Z")

</div>

NP is the type of stuff I set up at work all the time.

---

<div class="post-metadata">

**Author:** ![Droid](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/d/54ee81/32.png) [@Droid](https://forums.teamphoenixrising.net/u/Droid)\
**Post date:** [10 November 2006 19:51 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/5 "2006-11-10T19:51:11Z")

</div>

I used a colour change macro in the Rosetta stats sheet I used to run. It changed the colour of the font, but I’m guessing the principle is the same:

Sub colourchange()  
’  
’ colourchange Macro  
’ Macro recorded 24/04/05 by Andrew Young  
’  
’

For x = 1 To 300

If Cells(x, 6).Value \< “0” Then  
Cells(x, 6).Font.Color = RGB(255, 0, 0)  
End If  
If Cells(x, 6).Value \> “0” Then  
Cells(x, 6).Font.Color = RGB(0, 128, 0)  
End If  
If Cells(x, 6).Value = “0” Then  
Cells(x, 6).Font.Color = RGB(0, 0, 0)  
End If  
If Cells(x, 6).Value = “NEW” Then  
Cells(x, 6).Font.Color = RGB(0, 0, 255)  
End If  
If Cells(x, 6).Value = “Position” Then  
Cells(x, 6).Font.Color = RGB(0, 0, 0)  
End If  
If Cells(x, 6).Value = “Change” Then  
Cells(x, 6).Font.Color = RGB(0, 0, 0)  
End If  
If Cells(x, 6).Value = “” Then  
Cells(x, 6).Font.Color = RGB(0, 0, 0)  
End If  
Next x

End Sub

I’m guessing the solution could be similar, but I can’t find the right syntax. I’ll search and get back to you.

---

<div class="post-metadata">

**Author:** ![Kevin](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/k/2acd7d/32.png) [@Kevin](https://forums.teamphoenixrising.net/u/Kevin)\
**Post date:** [10 November 2006 23:47 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/6 "2006-11-10T23:47:00Z")

</div>

You could use:  
Cells(x,y).Interior.ColorIndex = Number  
or  
Cells(x,y).Interior.Color = RGB(r,g,b)

---

<div class="post-metadata">

**Author:** ![Droid](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/d/54ee81/32.png) [@Droid](https://forums.teamphoenixrising.net/u/Droid)\
**Post date:** [11 November 2006 05:32 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/7 "2006-11-11T05:32:36Z")

</div>

Cheers Kev!! 👍 The “RGB(r,g,b)” does not work in my Office 97 when I use say RGB(255,255,0). It comes back with error code 1004. Works OK with the number though. I’ve also had to put in a line to change the font colour to a contrasting colour so that you can read the cell value.

Sub colourchange()  
’  
’ colourchange Macro  
’ Macro recorded 24/04/05 by Andrew Young

For x = 1 To 300

If Cells(x, 6).Value \< “0” Then ’ the 6 in the brackets refers to the 6th column in the spreadsheet, change it to whatever you want  
Cells(x, 6).Interior.ColorIndex = 3  
Cells(x, 6).Font.Color = 16777215  
End If  
Next x  
End Sub

and then just add different “If…End If” statement for the different cell states inside the For - Next statement(green background, white text for positive values, white background, black text for zero values, etc.)

Tested it, it works OK

---

<div class="post-metadata">

**Author:** ![Kevin](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/k/2acd7d/32.png) [@Kevin](https://forums.teamphoenixrising.net/u/Kevin)\
**Post date:** [11 November 2006 12:49 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/8 "2006-11-11T12:49:01Z")

</div>

You get that error by using the colorindex property and not color.

---

<div class="post-metadata">

**Author:** ![Droid](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/d/54ee81/32.png) [@Droid](https://forums.teamphoenixrising.net/u/Droid)\
**Post date:** [11 November 2006 13:32 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/9 "2006-11-11T13:32:33Z")

</div>

Ah! sorted. Thanks again Kev. I’m learning more every time I come here.

---

<div class="post-metadata">

**Author:** ![Kevin](https://forums.teamphoenixrising.net/letter_avatar_proxy/v4/letter/k/2acd7d/32.png) [@Kevin](https://forums.teamphoenixrising.net/u/Kevin)\
**Post date:** [11 November 2006 13:42 UTC](https://forums.teamphoenixrising.net/t/excel-question/13729/10 "2006-11-11T13:42:35Z")

</div>

I think we all do.
