Query Changes

M

MarkS

Hi,
This query creates a conditional formatting query, the result is inconstant.
The query change the values in ‘sOrString’ some time the column changes and
others the row changes.

iRowCounter = 5
Do Until Sheets("Control").Range("C" & iRowCounter).Value = ""
sOrString = ""
For iCounter = 5 To 14
If iCounter <> iRowCounter Then
sOrString = sOrString & " D" & iRowCounter & " = D" & iCounter & ","
End If
Next
sOrString = Right(sOrString, Len(sOrString) - 1)
sOrString = Left(sOrString, Len(sOrString) - 1)
Sheets("Control").Range("D" & iRowCounter).FormatConditions.Delete
Sheets("Control").Range("D" & iRowCounter).FormatConditions.Add
Type:=xlExpression, Formula1:= _
"=NOT(OR(" & sOrString & "))"
Sheets("Control").Range("D" &
iRowCounter).FormatConditions(1).Interior.ColorIndex = 4
Sheets("Control").Range("D" & iRowCounter).FormatConditions.Add
Type:=xlExpression, Formula1:= _
"=OR(" & sOrString & ")"
Sheets("Control").Range("D" &
iRowCounter).FormatConditions(2).Interior.ColorIndex = 3
iRowCounter = iRowCounter + 1
Loop

Any ideas on how to fix this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top