My objective is to select cells on row for columns F thru X and have conditional formatting comparing to cell on same row in column z. I need to loop through row 3 thru 70.
Sub FindLowestCost()
Dim i As Integer
For i = 3 To 70
Range("F3,H3,J3,L3,N3,P3,R3,T3,V3,X3").Select '****this line is my problem. don't know format inside ()
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=Cells(i, 26).Value
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16753384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Next i
End Sub
My problem is in the selection: Something like this below doesn't appear to work. It loops through but the conditional format doesn't stick:
Sub FindLowestCost()
Dim i As Integer
For i = 3 To 70
Cells(i, 6).Select Cells(i, 8).Select
Cells(i, 10).Select
Cells(i, 12).Select
Cells(i, 14).Select
Cells(i, 16).Select
Cells(i, 18).Select
Cells(i, 20).Select
Cells(i, 22).Select
Cells(i, 24).Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=Cells(i, 26).Value
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16753384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Next i
End Sub
Thanks for the suggestions. Randy
Sub FindLowestCost()
Dim i As Integer
For i = 3 To 70
Range("F3,H3,J3,L3,N3,P3,R3,T3,V3,X3").Select '****this line is my problem. don't know format inside ()
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=Cells(i, 26).Value
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16753384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Next i
End Sub
My problem is in the selection: Something like this below doesn't appear to work. It loops through but the conditional format doesn't stick:
Sub FindLowestCost()
Dim i As Integer
For i = 3 To 70
Cells(i, 6).Select Cells(i, 8).Select
Cells(i, 10).Select
Cells(i, 12).Select
Cells(i, 14).Select
Cells(i, 16).Select
Cells(i, 18).Select
Cells(i, 20).Select
Cells(i, 22).Select
Cells(i, 24).Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=Cells(i, 26).Value
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16753384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Next i
End Sub
Thanks for the suggestions. Randy