Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Formatting VB

Status
Not open for further replies.

Sandman007

Programmer
Jun 20, 2001
47
US
Here is the code that I have written and then I will explain to you my problems:

Dim i, j, k
i = "AU5"
j = "AU6"
k = "AU7"

Range(j).Select
' If Range(strRange) < 0 Then
' Range(strRange) = 0
' End If
Dim n
n = Selection.Interior.ColorIndex

Range(k).Select
Dim ohoh
ohoh = Selection.Interior.ColorIndex


If (n = 3) Or (ohoh = 3) Then
Range(i).Select
With Selection.Interior
.ColorIndex = 3
End With
ElseIf (n = 6) Or (ohoh = 6) Then
Range(i).Select
With Selection.Interior
.ColorIndex = 6
End With
Else
Range(i).Select
With Selection.Interior
.ColorIndex = 4
End With
End If



My problem is that this only identifies the coloindex of the formatted cell. I need it to evaluate the color given to the cell from the conditional formatting. Does anyone know the vb for that? (i.e. Selection.Interior.ColorIndex)

I actually want the vb that identifies the conditional formatted cell color rather than the interior. Please Help!
 
This MAY help you. The code that I think you are looking
for is:
x = Range(&quot;A1&quot;).FormatConditions(1).Interior.ColorIndex
However, this colorindex will only be valid if the
condition is TRUE. You will also need to evalute the
value of the cell to determine is the condition is
true or false.

- vbMax

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top