| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 87582 | 2008-02-26 22:32:00 | Excel Guru's - Enter here | SolMiester (139) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 643933 | 2008-02-26 22:32:00 | Hi, a colleague has a spreadsheet where she would like the cell font colour to change depending on the result of the if statement in the cell?. Can this be done? Thank you |
SolMiester (139) | ||
| 643934 | 2008-02-26 22:39:00 | Conditional Formatting should do it | jwil1 (65) | ||
| 643935 | 2008-02-27 00:18:00 | Conditional Formatting should do it Only if there's three or less conditions. Here's an example, which you should be able to adapt. (using vba) Private Sub Worksheet_Change(ByVal Target As Range) Dim Rng As Range, c As Range, RngIntersect As Range Set Rng = Range("A1:Z6665") Set RngIntersect = Intersect(Rng, Target) If Not RngIntersect Is Nothing Then For Each c In Target Select Case c.Value Case Is = "Auckland": c.Font.Color = vbCyan Case Is >= "Wellington": c.Interior.Color = vbGreen Case Is >= 3: c.Font.Color = vbRed Case Is >= 1: c.Interior.Color = vbYellow Case Else: c.Interior.ColorIndex = xlNone End Select Next c End If End Sub |
the_bogan (9949) | ||
| 643936 | 2008-02-27 01:07:00 | Only if there's three or less conditions. Here's an example, which you should be able to adapt. (using vba) Private Sub Worksheet_Change(ByVal Target As Range) Dim Rng As Range, c As Range, RngIntersect As Range Set Rng = Range("A1:Z6665") Set RngIntersect = Intersect(Rng, Target) If Not RngIntersect Is Nothing Then For Each c In Target Select Case c.Value Case Is = "Auckland": c.Font.Color = vbCyan Case Is >= "Wellington": c.Interior.Color = vbGreen Case Is >= 3: c.Font.Color = vbRed Case Is >= 1: c.Interior.Color = vbYellow Case Else: c.Interior.ColorIndex = xlNone End Select Next c End If End Sub LOL, mate, thats well over my head! |
SolMiester (139) | ||
| 643937 | 2008-02-27 01:31:00 | If you were to right click on the sheet tab (for example, it says sheet1 by default), you can choose the option view code. Simply paste the code I pasted in there, and adjust as needed. For example, replace Auckland with the word you're trying to highlight, and the word would come up in Cyan. If there is a specific example you would like, feel free to PM me and I can sort something out. |
the_bogan (9949) | ||
| 643938 | 2008-02-27 02:05:00 | Thanks Bogan, will keep that in mind...... | SolMiester (139) | ||
| 1 | |||||