lunes, 6 de mayo de 2013

capturas






Factura Larga


Private Sub Can1_Change()
Sub1.Value = Pre1.Value * Can1.Value
Total = Val(Total) + Val(Sub1)
End Sub
Private Sub Can2_Change()
Sub2.Value = Pre2.Value * Can2.Value
Total = Val(Total) + Val(Sub2)
End Sub

Private Sub Cod1_Change()
If Nit.Value = "" Then
    MsgBox "Debe ingresar todos los datos del cliente", vbOKOnly, "Resultado"
    Nit.SetFocus
End If

Sheets("Base_de_Datos").Select
Range("A1").Select

On Error Resume Next
    Cells.Find(What:=Cod1.Value, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate

ActiveCell.Offset(0, 1).Select
Pro1 = ActiveCell
ActiveCell.Offset(0, 1).Select
Pre1 = ActiveCell
ActiveCell.Offset(0, 1).Select
Exi1 = ActiveCell

End Sub

Private Sub Cod2_Change()
If Cod1.Value = "" Then
    MsgBox "Debe ingresar datos en la fila 1", vbOKOnly, "Resultado"
    Cod1.SetFocus
End If

Sheets("Base_de_Datos").Select
Range("A1").Select

On Error Resume Next
    Cells.Find(What:=Cod2.Value, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate

ActiveCell.Offset(0, 1).Select
Pro2 = ActiveCell
ActiveCell.Offset(0, 1).Select
Pre2 = ActiveCell
ActiveCell.Offset(0, 1).Select
Exi2 = ActiveCell
End Sub

Private Sub CommandButton1_Click()
Sheets("Clientes").Select
Range("A1").Select

If comparacion.Caption <> Nit.Value Then
    Range("A2").Select
    Do While Not IsEmpty(ActiveCell)
        ActiveCell.Offset(1, 0).Select
    Loop
   
    ActiveCell = Nombre.Value
    ActiveCell.Offset(0, 1).Select
    ActiveCell = Direccion.Value
    ActiveCell.Offset(0, 1).Select
    ActiveCell = Nit.Value
End If

Sheets("Facturación").Select
Range("E11").Select
ActiveCell = NoFact.Caption
Range("B13").Select
ActiveCell = Nombre.Value
Range("E13").Select
ActiveCell = Nit.Value
Range("B15").Select
ActiveCell = Direccion.Value

Range("A20").Select

ActiveCell = Cod1.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pro1.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pre1.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Can1.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Sub1.Value

Sheets("Base_de_Datos").Select
Range("A1").Select

On Error Resume Next
    Cells.Find(What:=Cod1.Value, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
   
    ActiveCell.Offset(0, 3).Select
    ActiveCell = ActiveCell - Val(Can1)

Sheets("Facturación").Select
Range("A21").Select
ActiveCell = Cod2.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pro2.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pre2.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Can2.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Sub2.Value

Range("A22").Select
ActiveCell = Cod3.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pro3.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pre3.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Can3.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Sub3.Value

Range("A23").Select
ActiveCell = Cod4.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pro4.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Pre4.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Can4.Value
ActiveCell.Offset(0, 1).Select
ActiveCell = Sub4.Value

MsgBox "Los datos fueron guardados con éxito", vbOKOnly, "Resultado"

[XFD1] = [XFD1] + 1



Private Sub Nit_Change()
Sheets("Clientes").Select
Range("A1").Select

On Error Resume Next
    Cells.Find(What:=Nit.Value, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate

    comparacion.Caption = ActiveCell

If comparacion.Caption = Nit.Value Then
    Selection.Offset(, -2).Select
    Nombre.Value = ActiveCell
    Selection.Offset(, 1).Select
    Direccion.Value = ActiveCell
End If
End Sub


Private Sub UserForm_Initialize()
Nit.SetFocus
Fecha.Value = Date
Sheets("Facturación").Select
Dim fact As Double
fact = [XFD1] + 1
NoFact.Caption = fact
End Sub