Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>(Credit goes to Tim Williams)</p> <p>The issue seems to have to do something with the location of the active cell, changing during the process. The following code works and will be used (I also corrected another error I couldn't see before):</p> <pre><code>T = time.Address(True, False) ' here I initially forgot to update the row (not related to problem) Z1 = Cells(tline, t1.Column).Address Z2 = Cells(tline, t2.Column).Address Z3 = Cells(tline, t3.Column).Address Z4 = Cells(tline, t4.Column).Address fnc1 = "=OR(AND(" &amp; Z1 &amp; "&lt;=" &amp; T &amp; ";" &amp; T &amp; "&lt;" &amp; Z2 &amp; ");AND(" &amp; Z2 &amp; "&lt;" &amp; Z1 &amp; ";" &amp; Z1 &amp; "&lt;=" &amp; T &amp; ");AND(" &amp; T &amp; "&lt;" &amp; Z2 &amp; ";" &amp; Z2 &amp; "&lt;" &amp; Z1 &amp; "))" fnc2 = "=OR(AND(" &amp; Z2 &amp; "&lt;=" &amp; T &amp; ";" &amp; T &amp; "&lt;" &amp; Z3 &amp; ");AND(" &amp; Z3 &amp; "&lt;" &amp; Z2 &amp; ";" &amp; Z2 &amp; "&lt;=" &amp; T &amp; ");AND(" &amp; T &amp; "&lt;" &amp; Z3 &amp; ";" &amp; Z3 &amp; "&lt;" &amp; Z2 &amp; "))" fnc3 = "=OR(AND(" &amp; Z3 &amp; "&lt;=" &amp; T &amp; ";" &amp; T &amp; "&lt;" &amp; Z4 &amp; ");AND(" &amp; Z4 &amp; "&lt;" &amp; Z3 &amp; ";" &amp; Z3 &amp; "&lt;=" &amp; T &amp; ");AND(" &amp; T &amp; "&lt;" &amp; Z4 &amp; ";" &amp; Z4 &amp; "&lt;" &amp; Z3 &amp; "))" Dim currentLine As Range Set currentLine = Range(Cells(dline, data.Column), Cells(dline, data.Column).Offset(0, width)) currentLine.Select ' &lt;- neccessary change solving the problem Set frmt1 = currentLine.FormatConditions.Add(XlFormatConditionType.xlExpression, Formula1:=fnc1) Set frmt2 = currentLine.FormatConditions.Add(XlFormatConditionType.xlExpression, Formula1:=fnc2) Set frmt3 = currentLine.FormatConditions.Add(XlFormatConditionType.xlExpression, Formula1:=fnc3) frmt1.Interior.Color = RGB(255, 0, 0) frmt2.Interior.Color = RGB(0, 255, 0) frmt3.Interior.Color = RGB(0, 0, 255) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload