Hi all,
Syntax
expression.Match( Arg1, Arg2, Arg3 )
In code below I have one of three expressions just to make code easy to read.
Arg1=C42. After first loop Arg1 must be C60 etc etc.
How to change Arg1 in match function?
Sub CondFormat_AddTypeXlExpression()
Dim rng30 As range
Dim rng31 As range
Dim rng32 As range
'Dim rng32 As Variant
Dim i As Long
Set rng30 = range("C42:C56")
Set rng31 = range("B1")
Set rng32 = range("C42")
For i = 1 To 8
With rng30
.FormatConditions.Delete
.HorizontalAlignment = xlLeft
End With
rng30.Select
selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(AND(rng31<>""Apples"";rng31<>""Oranges"";MATCH(rng32;Sheet5!$A$5:$A$20;0)))" 'My "rng32" variable doesn't work
'"=AND(AND(rng31<>""Apples"";rng31<>""Oranges"";MATCH(C42;Sheet5!$A$5:$A$20;0)))" 'With this line it works, but only before the first loop.
selection.FormatConditions(selection.FormatConditions.Count).SetFirstPriority
With selection.FormatConditions(1).Font
.color = RGB(255, 0, 0)
End With
With selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.color = RGB(0, 32, 96)
End With
selection.FormatConditions(1).StopIfTrue = False
Set rng30 = rng30.Offset(18)
Set rng31 = rng31.Offset(, 2)
Set rng32 = rng32.Offset(18)
Next i
End Sub
Any help will be greatly appreciated.
Thanks!
Bookmarks