Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi Kate,
I have written you a program to help you out. You will need to paste this into a module in the Visual Basic Editor. Press <Alt-F11 to open the VB Editor, go to View Project Explorer (don't worry if nothing happens because maybe you can already see it), then look for a project called "VBAProject (YourWorkbookName)". Right click on this and do Insert Module. You will see a blank page on the right hand side. Copy the text below and paste it in there. Sub Kate() For x = 1 To 550 If Cells(x, 3).Value = "cds" Then Cells(x, 3).Font.ColorIndex = 5 If Cells(x, 3).Value = "vgh" Then Cells(x, 3).Font.ColorIndex = 5 If Cells(x, 3).Value = "bn" Then Cells(x, 3).Font.ColorIndex = 3 If Cells(x, 3).Value = "cda" Then Cells(x, 3).Font.ColorIndex = 3 If Cells(x, 3).Value = "khg" Then Cells(x, 3).Font.ColorIndex = 45 Next x End Sub Now go back to the excel window and do Tools Macro Macros and do the one called Kate. I think you will see quite easily how to modify the code above to give you what you need. You can add more conditions in there if you want just by copying the lines. If you want to change the fill on the cells instead of the font colour, use the word Interior instead of the word Font. Here is another program you can use in the same way which will just give you the numbers you need for each of the main colours, in case you want to choose other ones. Sub colourfinder() Dim x As Integer, writerow As Integer, writecol As Integer x = 1 writerow = 1 writecol = 1 Do Until x = 57 For writecol = 1 To 8 Cells(writerow, writecol).Value = x Cells(writerow, writecol).Interior.ColorIndex = x x = x + 1 Next writecol writerow = writerow + 1 Loop End Sub -- Allllen "kate" wrote: Could you please help me? I am trying to format text to highlight different colours depending on code e.g cds (I would like to be blue) and vgh ( I would like to be blue) bn (I would like to be red) cda ( I would like to be orange) and khg (I would like to be orange) and so on... The data range is c1:c550 with various names hope you can help thankyou Kate |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional Formatting when inserting a row | Excel Worksheet Functions | |||
Conditional formatting : amount of decimals | Excel Discussion (Misc queries) | |||
Formulas dealing with text data | Excel Worksheet Functions | |||
How do I apply conditional formatting to a text box | Excel Worksheet Functions | |||
Conditional Formatting based on Text within Text | Excel Discussion (Misc queries) |