Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

FORM BUSCAR

Buscar

CommandButton5
Label5
Frame1
CommandButton3

TxtFiltro1 CommandButton4

Label1,2,3,4 CommandButton5

ListBox1

'CERRAR FORMULARIO
Private Sub CommandButton2_Click()
Unload Me
End Sub
'
'ABRIR EL FORMULARIO PARA MODIFICAR
Private Sub CommandButton3_Click()
If Me.ListBox1.ListIndex < 0 Then
MsgBox "No se ha elegido ningún registro", vbExclamation, "EXCELeINFO"
Else
Modificar.Show
End If
End Sub
'
'ELIMINAR EL REGISTRO
Private Sub CommandButton4_Click()
Pregunta = MsgBox("Está seguro de eliminar el registro?", vbYesNo + vbQuestion,
"EXCELeINFO")
If Pregunta <> vbNo Then
ActiveCell.EntireRow.Delete
' Fila = Me.ListBox1.ListIndex + 2
' Rows(Fila).Delete
' Application.ScreenUpdating = True
End If
End Sub
Private Sub CommandButton5_Click()
On Error GoTo Errores
If Me.txtFiltro1.Value = "" Then Exit Sub
Me.ListBox1.Clear
j=1
For i = 1 To 18
If Cells(i, j).Offset(0, 2).Value = CInt(Me.txtFiltro1.Value) Then
Me.ListBox1.AddItem Cells(i, j)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Cells(i, j).Offset(0, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Cells(i, j).Offset(0, 2)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = Cells(i, j).Offset(0, 3)
Else
End If
Next i
Exit Sub
Errores:
MsgBox "No se encuentra.", vbExclamation, "EXCELeINFO"
End Sub

'ACTIVAR LA CELDA DEL REGISTRO ELEGIDO


Private Sub ListBox1_Click()
Range("a2").Activate
Cuenta = Me.ListBox1.ListCount
For i = 0 To Cuenta - 1
If Me.ListBox1.Selected(i) Then
'MsgBox Me.ListBox1.List(i)
Valor = Me.ListBox1.List(i)
Sheets("Hoja1").Range("A2:A18").Find(What:=Valor, LookAt:=xlWhole,
After:=ActiveCell).Activate
End If
Next i

'Fila = Me.ListBox1.ListIndex + 2
'For i = 1 To 4
' Cells(Fila, 1).Activate
'Next i
End Sub

'DAR FORMATO AL LISTBOX Y TRAER DATOS DE LA TABLA


Private Sub UserForm_Initialize()
For i = 1 To 4
Me.Controls("Label" & i) = Cells(1, i).Value
Next i

With ListBox1
.ColumnCount = 4
.ColumnWidths = "60 pt;60 pt;60 pt;60 pt"
'.ColumnHeads = True
End With
''ListBox1.RowSource = "Tabla1"
End Sub

FORM MODIFICAR

Modificar

Label1 TextBox1

Label2 TextBox2

Label3 TextBox3

Label4 TextBox4

CommandButton1 CommandButton2

'ACTUALIZAR EL REGISTRO
Private Sub CommandButton1_Click()
For i = 1 To 4
ActiveCell.Offset(0, i - 1).Value = Me.Controls("TextBox" & i).Value
Next i
Unload Me
End Sub
'
'CERRAR FORMULARIO
Private Sub CommandButton2_Click()
Unload Me
End Sub
'
'LLENAR LOS CUADRO DE TEXTO CON LOS DATOS DEL REGISTRO ELEGIDO
Private Sub UserForm_Initialize()
For i = 1 To 4
Me.Controls("TextBox" & i).Value = ActiveCell.Offset(0, i - 1).Value
Next i
End Sub
HOJA DE CÁLCULO

You might also like