Adicionar una instrucción a un Evento

Me ayudaste con este Evento de la hoja "VISITAS"

Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
    If Target.Address(False, False) = "C14" Then
        [F6] = 0
        [F7] = [C14]
    End If
    If Target.Address(False, False) = "C7" Then
        If Target = "" Or Target = 0 Then
            Exit Sub
        End If
------- CREO QUE LA NUEVA INSTRUCCION DEBE PONERSE AQUI ------------
        Set h = Sheets("CLIENTES")
        Set b = h.Columns("C").Find(Target, lookat:=xlWhole)
        If Not b Is Nothing Then
            MsgBox "La última vez que este paciente nos visitó fue:" & vbCr & vbCr & _
                   h.Cells(b.Row, "Q") & " - " & h.Cells(b.Row, "P")
        End If
    End If
End Sub

Pero ahora necesito adicionarle una nueva instrucción y es la siguiente:

Cuando ingrese un dato en la celda "C7" primero revise si ese dato se encuentra registrado en la hoja "WebPage" en la columna "A" desde la fila 2 en adelante. Si lo encuentra, me saque un msgbox diciendome "El paciente tiene un 25% de Descuento por inscripción en la Página WEB". Ese msgbox que sea vbinformation. Luego de dar click en aceptar a ese msgbox termine la macro "Exit sub".

En caso que el dato no este contenido en "WebPage" entonces continua con la macro.

Respuesta
1

H o l a:

Te anexo la macro actualizada

Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
    If Target.Count > 1 Then Exit Sub
    If Target.Address(False, False) = "C14" Then
        [F6] = 0
        [F7] = [C14]
    End If
    If Target.Address(False, False) = "C7" Then
        If Target = "" Or Target = 0 Then
            Exit Sub
        End If
        '
        Set h = Sheets("WebPage")
        Set b = h.Columns("A").Find(Target, lookat:=xlWhole)
        If Not b Is Nothing Then
            MsgBox "El paciente tiene un 25% de Descuento por inscripción en la Página WEB", vbInformation
            Exit Sub
        End If
        '
        Set h = Sheets("CLIENTES")
        Set b = h.Columns("C").Find(Target, lookat:=xlWhole)
        If Not b Is Nothing Then
            MsgBox "La última vez que este paciente nos visitó fue:" & vbCr & vbCr & _
                   h.Cells(b.Row, "Q") & " - " & h.Cells(b.Row, "P")
        End If
    End If
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas