lundi 26 septembre 2016

Complex If Statements VBA

All,

I have the below conditional formatting rule. I would like to use to extract data onto another worksheet (CM) if the conditional formatting for the cell is TRUE.

However reading several forums it has become apparent that VBA cannot detect when a conditional formatted cell is "TRUE".

Alternatively as a work around I would like to place the below statement into a an if statement. (My conditional formatting statements)

I have two conditional format statements 1st in the hierarchy is; (Displaying red)

=AND(F1>D1,OR((S1/D1)>=1.15,T1>=200000))

2nd in the hierarchy is;(Displaying Orange)

=F1>D1

Can anyone suggest the way of doing this. (I seem to struggle with placing AND / OR statements into VBA)

Dim LR As Long
LR = Range("A1048576").End(xlUp).Row
For X = 9 To LR Step 1
If Range("F" & X).Interior.ColorIndex = 3 OR Range("F" & X).Interior.ColorIndex = 45 Then

Dim LR1 As Long
LR1 = CM.Range("A1048576").End(xlUp).Row
RP.Range("B" & X, "D" & X).Copy
CM.Range("A" & LR1 + 1, "C" & LR1 + 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

RP.Range("S" & X, "T" & X).Copy
CM.Range("D" & LR1 + 1, "E" & LR1 + 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
Else
End If
Next X

Also is there a way of telling which part of the IF statement is true as I would like to Tick a box "Critical" if the Red condition is met and "Non Critical" if the amber condition is met.

Picture added for context enter image description here

any help would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire