Adicionar instrucción a macro según nueva condición
H o l a D a n t e
Tengo el siguiente fragmento de macro:
Sub Buscar4()
Set h2 = Sheets("AGENDA")
Set h3 = Sheets("REAGENDAR")
h3.[D6:D22].ClearContents
'
If h3.[D4] = "" Then
MsgBox "Número de Registro Único (RU) de la cita está VACIO." & vbCrLf & "" & vbCrLf & "Por favor escriba el número de RU en el espacio correspondiente.", vbExclamation
[D4].Select
Exit Sub
End If
'
Set b = h2.Columns("R").Find(h3.[D4], lookat:=xlWhole)
If Not b Is Nothing Then
h3.[D6] = h2.Cells(b.Row, "B")
h3.[D7] = h2.Cells(b.Row, "C")
h3.[D8] = h2.Cells(b.Row, "D")
h3.[D9] = h2.Cells(b.Row, "E")
h3.[D10] = h2.Cells(b.Row, "F")
h3.[D11] = h2.Cells(b.Row, "G")
h3.[D12] = h2.Cells(b.Row, "H")
h3.[D13] = h2.Cells(b.Row, "I")
h3.[D14] = h2.Cells(b.Row, "J")
h3.[D15] = h2.Cells(b.Row, "K")
h3.[D16] = h2.Cells(b.Row, "L")
h3.[D17] = h2.Cells(b.Row, "M")
h3.[D18] = h2.Cells(b.Row, "N")
h3.[D19] = h2.Cells(b.Row, "O")
h3.[D20] = h2.Cells(b.Row, "P")
h3.[D21] = h2.Cells(b.Row, "Q")
h3.[D22] = h2.Cells(b.Row, "A")
If h3.[D6] <= Date Then
MsgBox "Lamentablemente el sistema solo permite reagendar citas mínimo con " & _
"24 horas de anticipación a la cita programada. " & vbCr & vbCr & _
"Si necesita registrar una nueva cita para este paciente, " & _
"favor dirijase a la sección de INGRESAR CITA. Gracias. ", vbInformation
'NUEVAS INSTRUCCIONES AQUI
h3.Activate
h3.Range("D6:D22").Select
Selection.ClearContents
h3.Range("D4").Select
Selection.ClearContents
ActiveWorkbook.Save
End If
Else
MsgBox "El número de Registro Único (RU) no existe en la AGENDA." & vbCrLf & "" & vbCrLf & "Por favor verifique e Intentelo de nuevo.", vbExclamation
[D4].Select
End If
End SubMe gustaria que me ayudaras en los siguiente, voy a crear una hoja llamada "Historial" y en ella voy a tener exactamente las mismas columnas de la hoja "AGENDA" es decir h2.
Esa hoja Historial quisiera que la llames entonces h4 es decir
Set h4 = Sheets("Historial")
Con el fin de que después del msgbox que está ahí y antes de borrar las celdas copie la misma fila encontrada en "AGENDA" a la hoja "Historial" desde la columna "A" hasta la columna "Q"
Y ahí si continua con las instrucciones que siguen.
1 respuesta
Respuesta de Dante Amor
2