viernes, 26 de noviembre de 2010

BOTNES PARA FORMULARIO

Private Sub TextBox1_Change()
Range("A9").FormulaR1C1 = TextBox1
Rem esta primer línea reemplaza a estas dos…… que te parece todavía mas corta
Range("A9").Select
ActiveCell.FormulaR1C1 = TextBox1
End Sub
CODIGO TEXTBOX-NOMBRES
Private Sub TextBox2_Change()
Range("B9").FormulaR1C1 = TextBox2
End Sub
CODIGO DIRECCION
Private Sub TextBox3_Change()
Range("C9").FormulaR1C1 = TextBox3
End Sub
BOTONES
1. INSERTAR
Private Sub CommandButton3_Click()
Range("A9").Select
Selection.EntireRow.Insert

TextBox1 = Empty

TextBox2 = Empty

TextBox3 = Empty

TextBox1.SetFocus

End Sub

2. CONSULTA
Private Sub CONSULTA_Click()
Cells.Find(What:=TextBox1, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
ActiveCell.Offset(0, 1).Select
TextBox2 = ActiveCell

ActiveCell.Offset(0, 1).Select

TextBox3 = ActiveCell

End Sub

3. BOTN BAJA
Private Sub CommandButton2_Click()
Selection.EntireRow.Delete

Range("A9").Select

TextBox1 = Empty

TextBox2 = Empty

TextBox3 = Empty

TextBox1.SetFocus

End Sub