If, then y else en VBA problema

Me marca error de copilacion Else sin IF en este código, ¿Dónde esta el error?

If Range("B4") = "Merida" Or Range("B4") = "Hermosillo" Then ActiveChart.PlotArea.Select
                                                                 ActiveChart.SetSourceData Source:=Range( _
                                                                 "'Dashboard 2'!$B$9,'Dashboard 2'!$E$9")
    Else
    If Range("B4") = "Mexicali" Then ActiveChart.PlotArea.Select
                                         ActiveChart.SetSourceData Source:=Range( _
                                          "'Dashboard 2'!$B$9:B11,'Dashboard 2'!$E$9:E11")
    Else
    If Range("B4") = "Guadalajara" Then ActiveChart.PlotArea.Select
                                          ActiveChart.SetSourceData Source:=Range( _
                                          "'Dashboard 2'!$B$9:B18,'Dashboard 2'!$E$9:E18")
    Else
    If Range("B4") = "Veracruz" Then ActiveChart.PlotArea.Select
                                          ActiveChart.SetSourceData Source:=Range( _
                                          "'Dashboard 2'!$B$9:B11,'Dashboard 2'!$E$9:E11")
    Else
    If Range("B4") = "Oficina Central" Then ActiveChart.PlotArea.Select
                                          ActiveChart.SetSourceData Source:=Range( _
                                          "'Dashboard 2'!$B$9:B43,'Dashboard 2'!$E$9:E43")
    Else
    If Range("B4") = "Monterrey" Then ActiveChart.PlotArea.Select
                                            ActiveChart.SetSourceData Source:=Range( _
                                         "'Dashboard 2'!$B$9:B15,'Dashboard 2'!$E$9:E15")

End IF

2 respuestas

Respuesta

Aparentemente te faltan un montón de "END IF", cada "IF" que abres debe cerrarse con su "END IF"

Respuesta
If Range("B4") = "Merida" Or Range("B4") = "Hermosillo" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9,'Dashboard 2'!$E$9")
ElseIf Range("B4") = "Mexicali" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B11,'Dashboard 2'!$E$9:E11")
'
ElseIf Range("B4") = "Guadalajara" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B18,'Dashboard 2'!$E$9:E18")
'
ElseIf Range("B4") = "Veracruz" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B11,'Dashboard 2'!$E$9:E11")
'
ElseIf Range("B4") = "Oficina Central" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B43,'Dashboard 2'!$E$9:E43")
'
ElseIf Range("B4") = "Monterrey" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B15,'Dashboard 2'!$E$9:E15")
End If

Me sigue arrojando el mismo error

If Range("B4") = "Merida" Or Range("B4") = "Hermosillo" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9,'Dashboard 2'!$E$9")
End If
If Range("B4") = "Mexicali" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B11,'Dashboard 2'!$E$9:E11")
End If
If Range("B4") = "Guadalajara" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B18,'Dashboard 2'!$E$9:E18")
End If
If Range("B4") = "Veracruz" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B11,'Dashboard 2'!$E$9:E11")
End If
If Range("B4") = "Oficina Central" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B43,'Dashboard 2'!$E$9:E43")
End If
If Range("B4") = "Monterrey" Then
    ActiveChart.PlotArea.Select
    ActiveChart.SetSourceData Source:=Range( _
    "'Dashboard 2'!$B$9:B15,'Dashboard 2'!$E$9:E15")
End If

si persiste el error envíame tu archivo [email protected]

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas