PDA

View Full Version : Solved: Conditional Formatting



CCkfm2000
06-10-2005, 09:34 AM
:banghead: Hi all.....

I have some data in sheet 2 with cell
a1 = 1
a2 = 2
a3 = 3
a4= 4
...... and so on
then in cell
b1 = D
b2 = N
b3 = DS
b4 = NS
... and so on
over 1000 lines.

In sheet 1 cell (b1) i do a =VLOOKUP(A1,Sheet2!A1:B4,2,FALSE)

What i need is the cell b1 formatted in different colours. Eg. D = blue . N = red , DS = Yellow , NS = green.

I've found some code that i've tried it works if i type in d or n but not when i do the vlookup.

Please help
:hi:

austenr
06-10-2005, 09:53 AM
Didn't see any code...Am I missing something?

austenr
06-10-2005, 10:22 AM
Try this...Change your index to the proper column (I, 2) , your values to the correct ones A,B,C and your font.colors

Sub Colors()
Dim FinalRow As Integer
Dim i As Integer

FinalRow = Cells(65536, 1).End(xlUp).Row

For i = 1 To FinalRow
If Cells(i, 1).Value = "F" Then
Cells(i, 1).Font.ColorIndex = 3
ElseIf Cells(i, 1).Value = "B" Then
Cells(i, 1).Font.ColorIndex = 50
ElseIf Cells(i, 1).Value = "C" Then
Cells(i, 1).Font.ColorIndex = 5
End If
Next i


End Sub

austenr
06-10-2005, 10:23 AM
You can find a list of font colors in the KB.

MWE
06-10-2005, 10:58 AM
Conditional formatting for more than 3 conditions has been written up in the KB; Relevant Item (http://www.vbaexpress.com/kb/getarticle.php?kb_id=90&PHPSESSID=efc7a2399168522c483ba641f19c9b4c)

CCkfm2000
06-17-2005, 09:34 AM
thanks all for the help....

mdmackillop
06-17-2005, 10:11 AM
This thread has been split for the new subject. "Run Outlook from Excel"
MD

CCkfm2000
06-17-2005, 10:18 AM
sorry new to all this....

mdmackillop
06-17-2005, 10:22 AM
No problem, its just that you may not get Outlook experts responding under your "Solved formatting" heading