Hi all,
I did a macro, it works well in Excel 2010, but in 2007 it triggers "Compile Error (Syntax Error)" on the first IF... THEN, I'd need have the macro working in 2007 and 2003, besides 2010:
_______________________________________________________
Anybody knows how to do this?
Thanks.
I did a macro, it works well in Excel 2010, but in 2007 it triggers "Compile Error (Syntax Error)" on the first IF... THEN, I'd need have the macro working in 2007 and 2003, besides 2010:
Code:
Public Sub Color()
Dim DataRange As Range
Dim cell As Range
Set DataRange = Range("A1:ZZ500")
For Each cell In DataRange.Cells
If (Not IsEmpty(cell)) And (cell.Value = "VERDE") Then
cell.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
cell.Value = ""
End If
If (Not IsEmpty(cell)) And (cell.Value = "AMARILLO") Then
cell.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
cell.Value = ""
End If
If (Not IsEmpty(cell)) And (cell.Value = "NARANJA") Then
cell.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
cell.Value = ""
End If
If (Not IsEmpty(cell)) And (cell.Value = "ROJO") Then
cell.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
cell.Value = ""
End If
If (Not IsEmpty(cell)) And (cell.Value = "VERDEAMARILLO") Then
cell.Select
With Selection.Interior
.Pattern = xlPatternLinearGradient
.Gradient.Degree = 135
.Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
.Color = 65535
.TintAndShade = 0
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
.Color = 5296274
.TintAndShade = 0
End With
cell.Value = ""
End If
If (Not IsEmpty(cell)) And (cell.Value = "VERDENARANJA") Then
cell.Select
With Selection.Interior
.Pattern = xlPatternLinearGradient
.Gradient.Degree = 135
.Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
.Color = 5296274
.TintAndShade = 0
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
.Color = 49407
.TintAndShade = 0
End With
cell.Value = ""
End If
If (Not IsEmpty(cell)) And (cell.Value = "NARANJAROJO") Then
cell.Select
With Selection.Interior
.Pattern = xlPatternLinearGradient
.Gradient.Degree = 135
.Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
.Color = 49407
.TintAndShade = 0
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
.Color = 255
.TintAndShade = 0
End With
cell.Value = ""
End If
Next
End Sub
Anybody knows how to do this?
Thanks.
Last edited by a moderator: