Ver Mensaje Individual
  #6 (permalink)  
Antiguo 28/05/2008, 11:13
Avatar de 3pies
3pies
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Desde una destilería
Mensajes: 2.584
Antigüedad: 20 años, 4 meses
Puntos: 144
Respuesta: busqueda con macros

Varias cosas:

Cambia el nombre del evento para que se te carguen los datos. Cámbiale el nombre a esto:
Código:
Private Sub CommandButton1_Click()
y le pones este otro:
Código:
Private Sub ComboBox1_Enter()
En realidad tienes que poner esto, en sustitución de lo que tienes:
Código:
Private Sub ComboBox1_Enter()
Range("a5").Select
Do While ActiveCell <> Empty
ActiveCell.Offset(1, 0).Select
ComboBox1.AddItem ActiveCell
Loop
End Sub
Y a continuación, esto otro:
Código:
Private Sub CommandButton2_Click()
'pasamos los datos a variables
codigo = Cells(ComboBox1.ListIndex + 6, 1)
nombre = Cells(ComboBox1.ListIndex + 6, 1).Offset(0, 1)
apellidos = Cells(ComboBox1.ListIndex + 6, 1).Offset(0, 2)
direccion = Cells(ComboBox1.ListIndex + 6, 1).Offset(0, 3)
telefono = Cells(ComboBox1.ListIndex + 6, 1).Offset(0, 4)
estado_civil = Cells(ComboBox1.ListIndex + 6, 1).Offset(0, 5)
cp = Cells(ComboBox1.ListIndex + 6, 1).Offset(0, 6)
'pasamos a la hoja 2
Sheets("Hoja2").Select
'escribimos los datos en la fila 6
Range("A6").Select
ActiveCell = codigo
ActiveCell.Offset(0, 1) = nombre
ActiveCell.Offset(0, 2) = apellidos
ActiveCell.Offset(0, 3) = direccion
ActiveCell.Offset(0, 4) = telefono
ActiveCell.Offset(0, 5) = estado_civil
ActiveCell.Offset(0, 6) = cp
End Sub
Salu2