VBA Conditional Formatting in Microsoft Excel
I am trying to CONDITIONAL FORMAT RANGE OF CELLS BASED ON ANOTHER RANGE OF CELLS I.E IF THEY MATCH (CELL FOR CELL) no format if one cell different to its counterpart formatting applied. I have achieved this in office 2007's excel which works as i want however the pc this program is destined for runs on excel 2003 so the conditional formatting doesn't work. So im looking to create vba code for it but cant get my head around converting the working formula into code : NOT (E8:R31=E54:R77) SETS OFF A CELL FILL. Thanks in advance to anyone who can help out.
Re: VBA Conditional Formatting in Microsoft Excel
From memory (of Excel 2003 and below) if you put the Conditional Format in the first cell and use the Format Painter on all subsequent cells it should work. Try the Conditional Format:=IF(E8<>E54,1,0) and format it accordingly. You may have to re-edit the Conditional Format formula to remove any $ automatically put in there by Excel - e.g. change "=IF($E$8<>$E$54,1,0)" to read as above. When you use the format painter on cells E8 thru to R31, it should increment the E8 and E54 in the Conditional Format formula for each cell individually (I think). If you do this in Excel 2007, it will just apply the same Conditional Format across the range you selected - gives the same result in Excel 2007, but may not translate back to 2003 properly.
Re: VBA Conditional Formatting in Microsoft Excel
It is not easy to find the exact solution but something similar to that can put more highlight on the same. I know this vbcode which can help you to get the results you are
expecting :
Code:
Private Sub Worksheet_Change (ByVal Target As Excel.Range)
If Not Intersect (Target, Range ("E4: E23")) Is Nothing Then
With Target
Select Case Target.Value
Case Is <0.5
. Interior.ColorIndex = 3
Case 0.5 To 0.79
. Interior.ColorIndex = 44
Case 0.8 To 0.99
. Interior.ColorIndex = 6
End Select
End With
End If
End Sub
Re: VBA Conditional Formatting in Microsoft Excel
I think this is possible with macro in Excel. For select the range [E4: E23] right click and choose format cells. Enables the Number tab and check the standard list Custom. In the Type field before [Red] [<0.49] Standard; [Orange] Standard. Let the Range [E4: E23] selected format and place, not Last conditional formatting. Fill in the fields of a condition to get the cell value is between 0.80 and 0.99. Click Format and click on Active Yellow. In condition 2 filled fields to obtain the cell value is between 1 and 1.33 and then click Format and select pattern in green and white police clicks. In the third condition value between 1.34 and 9.99. Active format click click click font and blue on white. And finally click OK twice. I hope you can take advantage of it.
Re: VBA Conditional Formatting in Microsoft Excel
Here is another sample vb code. Try to have a look on the same
Code:
Option Explicit
Private Sub Worksheet_Change (ByVal Target As Excel.Range)
Dim cell As Range
For Each cell In Range ("B2: H10")
If cell.Value = "X" Then cell.Font.ColorIndex = 15
If cell.Value = "L" Then cell.Font.ColorIndex = 3
If cell.Value = "T" Then cell.Font.ColorIndex = 41
If cell.Value = "R" Then cell.Font.ColorIndex = 10
If cell.Value = "R" Then cell.Font.FontStyle = "bold"
If cell.Value = "E" Then cell.Font.ColorIndex = 15
If cell.Value = "F" Then cell.Font.ColorIndex = 3
If cell.Value = "D" Then cell.Interior.ColorIndex = 3
If cell.Value = "" Then cell.Clear
Next
End Sub