Thread: Query Changes
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
MarkS MarkS is offline
external usenet poster
 
Posts: 49
Default Query Changes

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.ColorInd ex = 4
Sheets("Control").Range("D" & iRowCounter).FormatConditions.Add
Type:=xlExpression, Formula1:= _
"=OR(" & sOrString & ")"
Sheets("Control").Range("D" &
iRowCounter).FormatConditions(2).Interior.ColorInd ex = 3
iRowCounter = iRowCounter + 1
Loop

Any ideas on how to fix this