Cómo solucionar en macros el Error 13. No coinciden los tipos

Estoy trabajando con esta macro que se ejecuta con un cambio. Al tratar de insertar una fila en mi tabla, me sale el error 13 no coinciden los tipos en la línea resaltada en negrita.

Este es el archivo:

https://drive.google.com/file/d/0B0ObVk_A5LoVZUtNQ1Ytd2VJRDQ/view?usp=sharing

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("Estado_final")) Is Nothing Then
'Pinta toda la fila cuando está culminado el sitio
If Target = "Culminado" Then
Hoja1.ListObjects("MiTabla").ListRows(Target.Row - Range("inicio").Row).Range.Interior.Color = 5287936
Else
Exit Sub
End If
'Rellena los campos como No requiere
End If
If Not Application.Intersect(Target, Range("_1900")) Is Nothing Then
If Target = "No" Then
Intersect(Target.EntireRow, Range("Estado_1900")) = "No requiere"
Intersect(Target.EntireRow, Range("Estado_1900")).Offset(0, 3).Range("A1:D1").Interior.Color = 5287936
Target.Offset(0, 3) = "-"
Target.Offset(0, 4) = "-"
Target.Offset(0, 5) = "-"
End If
End If
End Sub

1 respuesta

Respuesta
1

Cuando insertas una línea o una columna en Target tienes cientos de celdas, entonces Target se convierte en un objeto, por eso no puedes comparar el objeto con un texto, por eso el error dice : "no coinciden los tipos"

Te anexo la macro actualizada

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 10 Then Exit Sub
    '
    If Not Application.Intersect(Target, Range("Estado_final")) Is Nothing Then
        'Pinta toda la fila cuando está culminado el sitio
        If Target.Value = "" Then Exit Sub
        For Each c In Target
            If c.Value = "Culminado" Then
                Hoja1.ListObjects("MiTabla").ListRows(Target.Row - Range("inicio").Row).Range.Interior.Color = 5287936
            End If
        Next
    End If
    '
    If Not Application.Intersect(Target, Range("_1900")) Is Nothing Then
        If Target = "No" Then
            Intersect(Target.EntireRow, Range("Estado_1900")) = "No requiere"
            Intersect(Target.EntireRow, Range("Estado_1900")).Offset(0, 3).Range("A1:D1").Interior.Color = 5287936
            Target.Offset(0, 3) = "-"
            Target.Offset(0, 4) = "-"
            Target.Offset(0, 5) = "-"
        End If
    End If
End Sub

.

'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

.

Avísame cualquier duda

.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas