lake1069
01-14-2020, 02:30 PM
I'm creating a dashboard. I've got two shapes oval 1 and oval 2. They are to change colors depending on the value of specific cells
I'm getting an error block if without end if.
What am i doing wrong here!
Sub Worksheet_Change(ByVal Target As Range)
' If Intersect(Target, Range("E10")) Is Nothing Then Exit Sub
If Target.Value >=-0.1And Target.Value <=0.1Then
ActiveSheet.Shapes.Range(Array("Oval 1")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(0,176,80)
EndWith
ElseIf Target.Value >=-0.29And Target.Value <0.29 Then
ActiveSheet.Shapes.Range(Array("Oval 1")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,255,0)
End With
Else
ActiveSheet.Shapes.Range(Array("Oval 1")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,0,0)
End With
If Intersect(Target, Range("N10"))IsNothing Then Exit Sub
If Target.Value >=-0.1And Target.Value <=0.1Then
ActiveSheet.Shapes.Range(Array("Oval 2")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(0,176,80)
End With
ElseIf Target.Value >=-0.29And Target.Value <0.29 Then
ActiveSheet.Shapes.Range(Array("Oval 2")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,255,0)
End With
Else
ActiveSheet.Shapes.Range(Array("Oval 2")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,0,0)
End With
End If
Range("A1").Select
End Sub
I'm getting an error block if without end if.
What am i doing wrong here!
Sub Worksheet_Change(ByVal Target As Range)
' If Intersect(Target, Range("E10")) Is Nothing Then Exit Sub
If Target.Value >=-0.1And Target.Value <=0.1Then
ActiveSheet.Shapes.Range(Array("Oval 1")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(0,176,80)
EndWith
ElseIf Target.Value >=-0.29And Target.Value <0.29 Then
ActiveSheet.Shapes.Range(Array("Oval 1")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,255,0)
End With
Else
ActiveSheet.Shapes.Range(Array("Oval 1")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,0,0)
End With
If Intersect(Target, Range("N10"))IsNothing Then Exit Sub
If Target.Value >=-0.1And Target.Value <=0.1Then
ActiveSheet.Shapes.Range(Array("Oval 2")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(0,176,80)
End With
ElseIf Target.Value >=-0.29And Target.Value <0.29 Then
ActiveSheet.Shapes.Range(Array("Oval 2")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,255,0)
End With
Else
ActiveSheet.Shapes.Range(Array("Oval 2")).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255,0,0)
End With
End If
Range("A1").Select
End Sub