Mensaje de msgbox en excel

Necesito una macro en donde al colocar un valor en la celda b1 salga la ventana preguntando si desea reemplazar o cambiar el valor de c1, si se le da el si que reemplace de lo contrario quedara igual

1 respuesta

Respuesta
1

H o l a 

prueba esto 

Private Sub Worksheet_Change(ByVal Target As Range)
'http://foro.todoexcel.com/macro-para-controlar-cambio-valor-una-celda-t32389.html
    Dim ValorAnterior, ValorActual
    If Intersect(Target, Range("B1")) Is Nothing Then Exit Sub
        ValorActual = Target.Cells(1).Value
        With Application
        On Error GoTo IrPorError
        .EnableEvents = False
        .Undo
        ValorAnterior = Target.Cells(1).Value
        .Undo
        If ValorAnterior <> Target.Value Then
            If MsgBox("El Valor ha cambiado" & vbNewLine & "¿Continúa?", vbYesNo + vbQuestion, "") = vbYes Then
            Target.Value = ValorActual
            Else
            Target.Value = ValorAnterior
            End If
    End If
    .EnableEvents = True
    End With
IrPorError:
    Application.EnableEvents = True
    If Err.Number <> 0 Then
    MsgBox "Error: " & Err.Number & vbNewLine & Err.Description
    End If
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas