Seleccionar columna desde otra hoja
Como hago para ejecutar esta instrucción desde otra hoja, ya que al hacerlo fuera de la hoja DataBase me muestra un error.
1 Respuesta
Ohh, no muestra la consulta completa, ok, en realidad esto es viene en referencia a una consulta anterior que hice, me facilitaron un código pero me muestra un error al ejecutar, te dejo la URL de la consulta:
H o l a
Te paso la macro
Nota:
Aquí cambia el textbox1 por text que verificará si el nombre existe en la hoja registro
Set b = h1.Columns("H").Find(h2.TextBox1.Value, lookat:=xlWhole)Sub Captura_Datos()
Dim strTitulo As String
Dim Continuar As String
Dim TransRowRng As Range
Dim NewRow As Integer
Application.ScreenUpdating = False
strTitulo = "Registro de autoridades"
'
'
Set h1 = Sheets("DataBase")
Set h2 = Sheets("Registro")
Set b = h1.Columns("H").Find(h2.TextBox1.Value, lookat:=xlWhole)
'
If Not b Is Nothing Then
MsgBox " No se puede registrar a esa persona ", vbCritical, "ATENCION !"
Exit Sub
End If
Set b = h1.Columns("H").Find(h2.TextBox1.Value, lookat:=xlWhole)
'
If Not b Is Nothing Then
MsgBox " No se puede registrar a esa persona ", vbCritical, "ATENCION !"
Exit Sub
End If
'
Continuar = MsgBox("Desea registrar los datos?", vbYesNo + vbInformation, strTitulo)
If Continuar = vbNo Then Exit Sub
Set TransRowRng = ThisWorkbook.Worksheets("DataBase").Cells(1, 1).CurrentRegion
NewRow = TransRowRng.Rows.Count + 1
With ThisWorkbook.Worksheets("DataBase")
.Cells(NewRow, 1).Value = Sheets("Registro").TextBox1.Value
.Cells(NewRow, 2).Value = Sheets("Registro").ComboBox1.Value
.Cells(NewRow, 4).Value = Sheets("Registro").ComboBox2.Value
.Cells(NewRow, 6).Value = Sheets("Registro").txt_numdoc.Value
.Cells(NewRow, 7).Value = Sheets("Registro").txt_tipodoc.Value
.Cells(NewRow, 8).Value = Sheets("Registro").txt_nomautor.Value
.Cells(NewRow, 9).Value = Sheets("Registro").txt_sexo.Value
.Cells(NewRow, 11).Value = Sheets("Registro").ComboBox3.Value
.Cells(NewRow, 12).Value = Sheets("Registro").ComboBox4.Value
.Cells(NewRow, 13).Value = Sheets("Registro").txt_descrip.Value
.Cells(NewRow, 14).Value = CDate(Sheets("Registro").txt_inicio.Value)
If Sheets("Registro").CheckBox1.Value = True Then
.Cells(NewRow, 15).Value = "INDEFINIDO"
Else
.Cells(NewRow, 15).Value = CDate(Sheets("Registro").txt_final.Value)
End If
.Cells(NewRow, 17).Value = Sheets("Registro").txt_documento.Value
.Cells(NewRow, 18).Value = CDate(Sheets("Registro").txt_fechadocu.Value)
.Cells(NewRow, 19).Value = "REGISTRADO"
.Cells(NewRow, 20).Value = Sheets("Registro").txt_detalles.Value
.Cells(NewRow, 21).Value = Sheets("Registro").txt_oficio.Value
.Cells(NewRow, 23).Value = CDate(Sheets("Registro").txt_fechaoficio.Value)
.Cells(NewRow, 24).Value = CDate(Sheets("Registro").txt_recepcion.Value)
.Cells(NewRow, 25).Value = Date
.Cells(NewRow, 26).Value = "PROCESADO"
.Cells(NewRow, 28).Value = "Usuario01"
.Cells(NewRow, 29).Value = "CONFORME"
.Cells(NewRow, 30).Value = Sheets("Registro").txt_detalles2.Value
.Cells(NewRow, 31).Value = Sheets("Registro").txt_email.Value
.Cells(NewRow, 32).Value = CDate(Sheets("Registro").txt_nacimiento.Value)
.Cells(NewRow, 33).Value = Sheets("Registro").txt_eleccion.Value
.Cells(NewRow, 34).Value = Date
End With
ThisWorkbook.Save
MsgBox ("Se agregó el registro n° " & NewRow - 5), vbInformation, strTitulo
Call Limpiar
Call Contador
Sheets("Registro").ComboBox1.Activate
End SubPor si falta algunos ajustes envíame a tu archivo [email protected] indicandome que falta ajustar
Valora para finalizar saludos!
Esta conforme mi estimado, el detalle es que solo quiero que me muestre el mensaje al ingresar dos nombres en especifico, por ejemplo "Pepe Lucho" y "Juan Carlos", ya que este registro puede contener nombres repeditos pero con otros campos distintos, y solo dos nombres en particular es lo que quiero impedir...gracias.
H o l a
Te entendería mejor si muestras unas cuantas imágenes como ingresas tus datos.
En cual hoja, fila, ¿columna hay que verificar si existen esos nombres?
Recomendaría que me enviaras tu archivo y adecuar el código
Mi email: [email protected], me pones los detalles en la hojas como deseas
- Compartir respuesta