Macro en worksheet_change me permita borrar datos al eliminar contenido en 2 celdas
Tengo el siguiente código
Private Sub Worksheet_Change(ByVal Target As Range)
'Exit Sub
If Not Intersect(Target, Range("F5, D4")) Is Nothing Then
If UCase(Target.Value) <> "" Then
Set h = ThisWorkbook.Sheets(Hoja31.Name) 'base de datos
Set h2 = ThisWorkbook.Sheets(Hoja32.Name) 'reporte produccion
Dim ultfiladatos As Long
Dim ultfilareporte As Long
ultfiladatos = h.Range("a" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For cont = 2 To ultfiladatos
clave = h.Cells(cont, 6)
ref = h.Cells(cont, 1)
orden = h.Cells(cont, 5)
If ref = h2.[D4] & h2.[d5] & h2.[d6] Then
ultfilareporte = h2.Range("c" & Rows.Count).End(xlUp).Row
[F1] = "Este pedido ya cuenta con datos."
h2.Cells(ultfilareporte + 1, 3) = clave
h2.Cells(ultfilareporte + 1, 4) = orden
End If
Next cont
Application.ScreenUpdating = True
ElseIf UCase(Target.Value) = Empty Then
MsgBox "Borrar datos"
Range("D4:f4").ClearContents
End If
End If
End Sub
Me funciona bien, pero al llegar en la parte donde borro los datos
De la celda F5 o de la celda D4
Este le tengo puedo que me salga un mensaje de "borrar datos"
Y posterior a ello me borre los datos que le solicito, sin embargo me sale error
"no coinciden los tipos"
Alguien me puede ayudar con la adecuacion de mi macro
1 Respuesta
Respuesta de Dante Amor
2