Private Sub BotonBAJA_Click()
If MsgBox("¿SEGURO QUE QUIERE ELIMINAR ESTE CLIENTE?", vbExclamation + vbYesNo) = vbYes Then
ActiveCell.EntireRow.Delete Shift = xlUp
ComboBoxNIF2 = ""
TextBoxNOMBRE = ""
TextBoxDIRECCION = ""
TextBoxCP = ""
TextBoxTELEF = ""
TextBoxEMAIL = ""
If MsgBox("EL CLIENTE HA SIDO ELIMINADO. ¿Quiere cerrar el formulario?", vbInformation + vbYesNo) =
vbYes Then
UserForm8.Hide
End If
End If
End Sub
Private Sub BotonCANCELAR_Click()
ComboBoxNIF2 = ""
TextBoxNOMBRE = ""
TextBoxDIRECCION = ""
TextBoxCP = ""
TextBoxTELEF = ""
TextBoxEMAIL = ""
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate
Loop
ComboBoxNIF.SetFocus
End Sub
Private Sub BotonBAJA_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, By
Val Y As Single)
BotonBAJA.BackStyle = fmBackStyleOpaque
BotonBAJA.ForeColor = vbWhite
End Sub
Private Sub ButtonCANCELAR_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Sin
gle, ByVal Y As Single)
ButtonCANCELAR.BackStyle = fmBackStyleOpaque
ButtonCANCELAR.ForeColor = vbWhite
End Sub
Private Sub ButtonModif_Click()
Application.ScreenUpdating = False
Sheets("Lista de Clientes").Activate
Cells(ComboBoxNIF2.ListIndex + 2, 1).Select
ActiveCell.Offset(0, 1) = TextBoxNOMBRE
ActiveCell.Offset(0, 2) = TextBoxDIRECCION
ActiveCell.Offset(0, 4) = CDbl(TextBoxCP)
ActiveCell.Offset(0, 3) = CDbl(TextBoxTELEF)
ActiveCell.Offset(0, 5) = TextBoxEMAIL
TextBoxNOMBRE = ""
TextBoxDIRECCION = ""
TextBoxCP = ""
TextBoxTELEF = ""
TextBoxEMAIL = ""
UserForm8.Hide
End Sub
Private Sub ButtonModif_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, B
yVal Y As Single)
ButtonModif.ForeColor = vbBlack
ButtonModif.BackStyle = fmBackStyleOpaque
End Sub
Private Sub ComboBoxNIF2_Change()
Application.ScreenUpdating = False
Sheets("Lista de Clientes").Activate
On Error Resume Next
Cells(ComboBoxNIF2.ListIndex + 2, 1).Select
TextBoxNOMBRE = ActiveCell.Offset(0, 1)
TextBoxDIRECCION = ActiveCell.Offset(0, 2)
TextBoxCP = ActiveCell.Offset(0, 4)
TextBoxTELEF = ActiveCell.Offset(0, 3)
TextBoxEMAIL = ActiveCell.Offset(0, 5)
End Sub
Private Sub ComboBoxNIF2_Enter()
Application.ScreenUpdating = False
ComboBoxNIF2.Clear
Sheets("Lista de Clientes").Select
Range("a2").Select
Do While Not IsEmpty(ActiveCell)
ComboBoxNIF2.AddItem ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Private Sub LabelAlta_Click()
ComboBoxNIF2.Enabled = False
ComboBoxNIF2.Visible = False
TextBoxNIF.Enabled = True
TextBoxNIF.Visible = True
BotonBAJA.Enabled = False
BotonBAJA.Visible = False
ButtonModif.Enabled = False
ButtonModif.Visible = False
Validar.Enabled = True
Validar.Visible = True
ButtonCANCELAR.Enabled = True
ButtonCANCELAR.Visible = True
TextBoxNIF = ""
End Sub
Private Sub LabelAlta_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByV
al Y As Single)
LabelAlta.ForeColor = &HFFFF00
End Sub
Private Sub LabelMod_Click()
TextBoxNIF.Enabled = False
TextBoxNIF.Visible = False
ComboBoxNIF2.Enabled = True
ComboBoxNIF2.Visible = True
ComboBoxNIF2 = ""
Validar.Enabled = False
Validar.Visible = False
ButtonModif.Enabled = True
ButtonModif.Visible = True
BotonBAJA.Enabled = True
BotonBAJA.Visible = True
ButtonCANCELAR.Enabled = True
ButtonCANCELAR.Visible = True
End Sub
Private Sub LabelMod_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByV
al Y As Single)
LabelMod.ForeColor = &H80FFFF
End Sub
Private Sub UserForm_Activate()
ComboBoxNIF2 = ""
TextBoxNIF = ""
TextBoxNOMBRE = ""
TextBoxDIRECCION = ""
TextBoxCP = ""
TextBoxTELEF = ""
TextBoxEMAIL = ""
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate
Loop
BotonBAJA.Enabled = False
BotonBAJA.Visible = False
ButtonModif.Enabled = False
ButtonModif.Visible = False
Validar.Enabled = False
Validar.Visible = False
ButtonCANCELAR.Enabled = False
ButtonCANCELAR.Visible = False
End Sub
Private Sub ButtonCANCELAR_Click()
ComboBoxNIF2 = ""
TextBoxNIF = ""
TextBoxNOMBRE = ""
TextBoxDIRECCION = ""
TextBoxCP = ""
TextBoxTELEF = ""
TextBoxEMAIL = ""
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate
Loop
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByV
al Y As Single)
LabelAlta.ForeColor = vbWhite
LabelMod.ForeColor = &H80FF80
BotonBAJA.BackStyle = fmBackStyleTransparent
BotonBAJA.ForeColor = &HFF&
ButtonCANCELAR.BackStyle = fmBackStyleTransparent
ButtonCANCELAR.ForeColor = &H80FF80
ButtonModif.ForeColor = &HFFFF&
ButtonModif.BackStyle = fmBackStyleTransparent
Validar.BackStyle = fmBackStyleTransparent
Validar.ForeColor = &HFFFF&
End Sub
Private Sub Validar_Click()
Application.ScreenUpdating = False
Sheets("Lista de Clientes").Activate
Range("a2").Activate
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate
Loop
ActiveCell = TextBoxNIF
ActiveCell.Offset(0, 1) = TextBoxNOMBRE
ActiveCell.Offset(0, 2) = TextBoxDIRECCION
ActiveCell.Offset(0, 4) = CDbl(TextBoxCP)
ActiveCell.Offset(0, 3) = CDbl(TextBoxTELEF)
ActiveCell.Offset(0, 5) = TextBoxEMAIL
Range("G2").Copy
ActiveCell.Offset(0, 6).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
TextBoxNIF = ""
TextBoxNOMBRE = ""
TextBoxDIRECCION = ""
TextBoxCP = ""
TextBoxTELEF = ""
TextBoxEMAIL = ""
UserForm8.Hide
End Sub
Private Sub Validar_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal
Y As Single)
Validar.BackStyle = fmBackStyleOpaque
Validar.ForeColor = &H0&
End Sub

Visual basic userform 8

  • 1.
    Private Sub BotonBAJA_Click() IfMsgBox("¿SEGURO QUE QUIERE ELIMINAR ESTE CLIENTE?", vbExclamation + vbYesNo) = vbYes Then ActiveCell.EntireRow.Delete Shift = xlUp ComboBoxNIF2 = "" TextBoxNOMBRE = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" If MsgBox("EL CLIENTE HA SIDO ELIMINADO. ¿Quiere cerrar el formulario?", vbInformation + vbYesNo) = vbYes Then UserForm8.Hide End If End If End Sub Private Sub BotonCANCELAR_Click() ComboBoxNIF2 = "" TextBoxNOMBRE = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Activate Loop ComboBoxNIF.SetFocus End Sub Private Sub BotonBAJA_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, By Val Y As Single) BotonBAJA.BackStyle = fmBackStyleOpaque BotonBAJA.ForeColor = vbWhite End Sub Private Sub ButtonCANCELAR_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Sin gle, ByVal Y As Single) ButtonCANCELAR.BackStyle = fmBackStyleOpaque ButtonCANCELAR.ForeColor = vbWhite End Sub Private Sub ButtonModif_Click() Application.ScreenUpdating = False Sheets("Lista de Clientes").Activate Cells(ComboBoxNIF2.ListIndex + 2, 1).Select ActiveCell.Offset(0, 1) = TextBoxNOMBRE ActiveCell.Offset(0, 2) = TextBoxDIRECCION ActiveCell.Offset(0, 4) = CDbl(TextBoxCP) ActiveCell.Offset(0, 3) = CDbl(TextBoxTELEF) ActiveCell.Offset(0, 5) = TextBoxEMAIL
  • 2.
    TextBoxNOMBRE = "" TextBoxDIRECCION= "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" UserForm8.Hide End Sub Private Sub ButtonModif_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, B yVal Y As Single) ButtonModif.ForeColor = vbBlack ButtonModif.BackStyle = fmBackStyleOpaque End Sub Private Sub ComboBoxNIF2_Change() Application.ScreenUpdating = False Sheets("Lista de Clientes").Activate On Error Resume Next Cells(ComboBoxNIF2.ListIndex + 2, 1).Select TextBoxNOMBRE = ActiveCell.Offset(0, 1) TextBoxDIRECCION = ActiveCell.Offset(0, 2) TextBoxCP = ActiveCell.Offset(0, 4) TextBoxTELEF = ActiveCell.Offset(0, 3) TextBoxEMAIL = ActiveCell.Offset(0, 5) End Sub Private Sub ComboBoxNIF2_Enter() Application.ScreenUpdating = False ComboBoxNIF2.Clear Sheets("Lista de Clientes").Select Range("a2").Select Do While Not IsEmpty(ActiveCell) ComboBoxNIF2.AddItem ActiveCell.Value ActiveCell.Offset(1, 0).Select Loop End Sub Private Sub LabelAlta_Click() ComboBoxNIF2.Enabled = False ComboBoxNIF2.Visible = False TextBoxNIF.Enabled = True TextBoxNIF.Visible = True BotonBAJA.Enabled = False BotonBAJA.Visible = False ButtonModif.Enabled = False ButtonModif.Visible = False Validar.Enabled = True Validar.Visible = True ButtonCANCELAR.Enabled = True ButtonCANCELAR.Visible = True TextBoxNIF = ""
  • 3.
    End Sub Private SubLabelAlta_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByV al Y As Single) LabelAlta.ForeColor = &HFFFF00 End Sub Private Sub LabelMod_Click() TextBoxNIF.Enabled = False TextBoxNIF.Visible = False ComboBoxNIF2.Enabled = True ComboBoxNIF2.Visible = True ComboBoxNIF2 = "" Validar.Enabled = False Validar.Visible = False ButtonModif.Enabled = True ButtonModif.Visible = True BotonBAJA.Enabled = True BotonBAJA.Visible = True ButtonCANCELAR.Enabled = True ButtonCANCELAR.Visible = True End Sub Private Sub LabelMod_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByV al Y As Single) LabelMod.ForeColor = &H80FFFF End Sub Private Sub UserForm_Activate() ComboBoxNIF2 = "" TextBoxNIF = "" TextBoxNOMBRE = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Activate Loop BotonBAJA.Enabled = False BotonBAJA.Visible = False ButtonModif.Enabled = False ButtonModif.Visible = False Validar.Enabled = False Validar.Visible = False ButtonCANCELAR.Enabled = False ButtonCANCELAR.Visible = False End Sub Private Sub ButtonCANCELAR_Click() ComboBoxNIF2 = "" TextBoxNIF = "" TextBoxNOMBRE = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = ""
  • 4.
    TextBoxEMAIL = "" DoWhile Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Activate Loop End Sub Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByV al Y As Single) LabelAlta.ForeColor = vbWhite LabelMod.ForeColor = &H80FF80 BotonBAJA.BackStyle = fmBackStyleTransparent BotonBAJA.ForeColor = &HFF& ButtonCANCELAR.BackStyle = fmBackStyleTransparent ButtonCANCELAR.ForeColor = &H80FF80 ButtonModif.ForeColor = &HFFFF& ButtonModif.BackStyle = fmBackStyleTransparent Validar.BackStyle = fmBackStyleTransparent Validar.ForeColor = &HFFFF& End Sub Private Sub Validar_Click() Application.ScreenUpdating = False Sheets("Lista de Clientes").Activate Range("a2").Activate Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Activate Loop ActiveCell = TextBoxNIF ActiveCell.Offset(0, 1) = TextBoxNOMBRE ActiveCell.Offset(0, 2) = TextBoxDIRECCION ActiveCell.Offset(0, 4) = CDbl(TextBoxCP) ActiveCell.Offset(0, 3) = CDbl(TextBoxTELEF) ActiveCell.Offset(0, 5) = TextBoxEMAIL Range("G2").Copy ActiveCell.Offset(0, 6).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False TextBoxNIF = "" TextBoxNOMBRE = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" UserForm8.Hide End Sub Private Sub Validar_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Validar.BackStyle = fmBackStyleOpaque Validar.ForeColor = &H0& End Sub