Hola necesito un código que me indique si estoy intentando grabar un dato ya existente

Pero que me permita mediante una opción similar a la de "GRABAR DATOS" que tengo seguir o cancelar

Os mando el código que tengo y agradecería me dijeseis donde debo insertar el código necesitado

También me gustaría si no es demasiado pedir saber que código necesito para que me muestre en el Textbox 28 el ultimo dato de la columna "A". Gracias por vuestra atención y FELICES FIESTAS

ALTAS
'AGREGAR DATOS
Private Sub userform_initialize()
ComboBox5.AddItem "Solicitud devolución Tasa"
ComboBox5.AddItem "Solicitud devolución anulación Denuncia"
ComboBox3.AddItem "Si"
ComboBox3.AddItem "No"
ComboBox2.AddItem "Estimado"
ComboBox2.AddItem "Desestimado"
ComboBox2.AddItem "Estimado Parcial"
End Sub
Private Sub CommandButton1_Click()
Hoja2.Select
i = Range("A" & Rows.Count).End(xlUp).Row + 1
'se agregan los nuevos datos
Range("A" & i).Value = TextBox27.Text
Range("B" & i).Value = TextBox26.Text
Range("C" & i).Value = TextBox25.Text
Range("D" & i).Value = TextBox24.Text
Range("E" & i).Value = TextBox23.Text
Range("F" & i).Value = TextBox6.Text
Range("G" & i).Value = TextBox7.Text
Range("H" & i).Value = TextBox8.Text
Range("I" & i).Value = ComboBox5.Text
Range("J" & i).Value = TextBox10.Text
Range("QUE" & i).Value = TextBox11.Text
Range("L" & i).Value = TextBox12.Text
Range("M" & i).Value = TextBox13.Text
Range("N" & i).Value = ComboBox3.Text
Range("O" & i).Value = TextBox15.Text
Range("P" & i).Value = TextBox16.Text
Range("QUE" & i).Value = TextBox17.Text
Range("R" & i).Value = TextBox18.Text
Range("ES" & i).Value = ComboBox2.Text
Range("T" & i).Value = TextBox20.Text
Range("U" & i).Value = TextBox21.Text
Range("V" & i).Value = TextBox22.Text
'mensaje de advertencia
If MsgBox("¿GRABAR DATOS?", vbExclamation + vbYesNo) = _
vbYes Then
Macro1
'Después de verificar que todos los datos están correctos
'se vacían los TextBox
TextBox27.Text = ""
TextBox26.Text = ""
TextBox25.Text = ""
TextBox24.Text = ""
TextBox23.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
ComboBox5.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
ComboBox3.Text = ""
TextBox15.Text = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox18.Text = ""
ComboBox2.Text = ""
TextBox20.Text = ""
TextBox21.Text = ""
TextBox22.Text = ""
'se cierra el if
End If
'se selecciona la hoja 1 para que el formulario
'aparezca en ella
Hoja1.Select
'se selecciona el rango B4 para ocultrlo detrás de un botón
Range("B4").Select
End Sub
Private Sub CommandButton2_Click()
'Botón de Cancelar
Unload Me
End
End Sub
'OCULTA EL FORMULARIO ALTAS
Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
Me.Hide 'se podría haber puesto ALTAS.Hide
'se coloca el cursor(foco) en el TextMModelo
TextBox27.SetFocus
End Sub

Añade tu respuesta

Haz clic para o