![]() |
add colours to caracters
I would like to add different colours to different numbers in an excel sheet.
So for example "1234" should be green every time when these determined caracters (numbers) appears on the sheet. Can I do it? And if yes, can i match more determined caracters with different coulours. Thanks! |
add colours to caracters
Hi Sheva,
You can easily accomplish this through CONDITIONAL FORMATTING. - Highlight the entire sheet (or column that will contain the number that you are searching for) - From the menu select FORMAT Conditional Format - From the box select CELL VALUE IS EQUAL TO - In the box beside that type in the value you are looking to highlight - Press the FORMAT button and select the color that you wish to apply to that number If you want to look for and change the color of other numbers, then click on ADD and repeat the above steps. HTH Tom "sheva" wrote: I would like to add different colours to different numbers in an excel sheet. So for example "1234" should be green every time when these determined caracters (numbers) appears on the sheet. Can I do it? And if yes, can i match more determined caracters with different coulours. Thanks! |
add colours to caracters
Option Explicit
'----------------------------------------------------------------- Private Sub Worksheet_Change(ByVal Target As Range) '----------------------------------------------------------------- Dim iPos As Long Const TEST_VALUE_1 As String = "1234" Const TEST_COLORINDEX_1 As Long = 10 Const TEST_VALUE_2 As String = "789" Const TEST_COLORINDEX_2 As Long = 5 On Error GoTo ws_exit: Application.EnableEvents = False With Target Select Case True Case InStr(CStr(.Value), TEST_VALUE_1) 0: .Characters(iPos, Len(TEST_VALUE_1)). _ Font.ColorIndex = TEST_COLORINDEX_1 Case InStr(CStr(.Value), TEST_VALUE_2) 0: .Characters(iPos, Len(TEST_VALUE_2)). _ Font.ColorIndex = TEST_COLORINDEX_2 'etc. End Select End With ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob Phillips (remove xxx from email address if mailing direct) "sheva" wrote in message ... I would like to add different colours to different numbers in an excel sheet. So for example "1234" should be green every time when these determined caracters (numbers) appears on the sheet. Can I do it? And if yes, can i match more determined caracters with different coulours. Thanks! |
All times are GMT +1. The time now is 12:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com