For next conditional

F

Faboboren

Hi

I have this code, and is not running properly. I want a conditional format
for numbers less than 0 to become in red. any idea, thanks?


Sub Conditional()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Sheets
With sht.Range("C7:C55")
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
End With
Next sht
End Sub
 
J

JLGWhiz

You had the cart before the horse:

Sub Conditional()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Sheets
With sht.Range("C7:C55")

.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
.FormatConditions(1).Font.ColorIndex = 3
End With
Next sht
End Sub
 
F

Faboboren

JLGWhiz,

Great, is working, thanks

JLGWhiz said:
You had the cart before the horse:

Sub Conditional()
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Sheets
With sht.Range("C7:C55")

.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
.FormatConditions(1).Font.ColorIndex = 3
End With
Next sht
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top