Está en la página 1de 8

CDIGO FACTURA

Modulo 1
Sub definir_inicio()
' Acceso directo: CTRL+d

Sheets("LFAC").Select
pr = Range("A2").Value
Sheets("MEN").Select
If pr <> "" Then MsgBox prompt:="ESTA ACCIN NO SE PUEDE EJECUTAR
PORQUE YA HAY FACTURAS INTRODUCIDAS", Buttons:=vbOKOnly, Title:="ERROR"
If pr <> "" Then End
fi = Range("L4").Value
Sheets("TFAC").Select
ActiveSheet.Unprotect
Range("H10003").Value = fi - 1
ActiveSheet.Protect
Sheets("MEN").Select
MsgBox prompt:="ESTE NUMERO HA SIDO DEFINIDO COMO NUMERO DE COMIENZO DE
FACTURAS", Buttons:=vbOKOnly, Title:="DEFINIDO"
End Sub

Modulo 7
Sub imprimir()
' Acceso directo: CTRL+h

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


End Sub

Modulo 8
Sub fact_ingr_guardar()
' Acceso directo: CTRL+i

Sheets("FAC").Select
Application.ScreenUpdating = False
If Range("D11").Value = "" Then End
If Range("K11").Value = "" Then End
If Range("K12").Value = "" Then End
x = 0
fac = Range("K12").Value
fec = Range("K11").Value
If fac <= Range("N12").Value Then
MsgBox prompt:="El nmero de factura ya existe. Fjese en el la celda
amarilla para ver la ltima factura", Buttons:=vbOKOnly, Title:="ERROR"
End If
If fac <= Range("N12").Value Then End
If fac - 1 > Range("N12").Value Then

__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ________________________________

(\ /)
( . .)
C()() { 1 }
MsgBox prompt:="Se ha dejado algn nmero de factura sin poner. Fjese
en el la celda amarilla para ver la ltima factura", Buttons:=vbOKOnly,
Title:="ERROR"
End If
If fac - 1 > Range("N12").Value Then End
If fec < Range("N13").Value Then
MsgBox prompt:="La factura no puede ser de fecha anterior a la ltima.
Fjese en el la celda amarilla para ver la ltima factura",
Buttons:=vbOKOnly, Title:="ERROR"
End If
If fec < Range("N13").Value Then End

ActiveSheet.Unprotect
Range("N12").Select
ActiveCell.FormulaR1C1 = "=MAX(TFAC!R[-10]C[-6]:R[9991]C[-6])"
Range("N13").Select
ActiveCell.FormulaR1C1 = "=MAX(TFAC!R[-11]C[-7]:R[9989]C[-7])"
Sheets("LFAC").Select
ActiveSheet.Unprotect
Range("A2").Select
While ActiveCell.Value <> ""
If ActiveCell.Value = fac Then x = 1
ActiveCell.Offset(1, 0).Select
Wend

If x = 0 Then
Sheets("FAC").Select
Range("R17:V40").Select
Selection.Copy
Sheets("LFAC").Select
Range("A10002").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D10002").Select
Selection.End(xlUp).Select
For a = 1 To 24
If ActiveCell.Value = 0 Then Selection.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
Next a
Range("A2:H10001").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect

Sheets("TFAC").Unprotect
Sheets("FAC").Select
Range("X17:AJ17").Select
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________

(\ /)
( . .)
C()() { 2 }
Selection.Copy
Sheets("TFAC").Select
Range("A10002").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A2:M10001").Select
Selection.Sort Key1:=Range("H2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect

Sheets("FAC").Select
Range("D11:H11,K11,D12,D13,D14,F13,H13,C17:J40").Select
Range("C17").Activate
Selection.ClearContents

MsgBox prompt:="Factura anotada.", Buttons:=vbOKOnly, Title:="ANOTADO"


End If
Sheets("FAC").Select

If x = 1 Then MsgBox prompt:="El nmero de factura ya existe.",


Buttons:=vbOKOnly, Title:="ERROR"
Range("D11").Select
Sheets("LFAC").Protect
ActiveSheet.Protect

End Sub

Modulo 9
Sub fact_ingr_buscar()
' Acceso directo: CTRL+j

Sheets("FMOD").Select
Application.ScreenUpdating = False
If Range("K12").Value = "" Then End
If Range("D11").Value <> 0 Then MsgBox prompt:="Hay datos de otra
factura. Brrelos para buscar otra pero se perdern si no los anota
antes.", Buttons:=vbOKOnly, Title:="ERROR"
If Range("D11").Value <> 0 Then End
ActiveSheet.Unprotect
Range("K12").Select
Application.CutCopyMode = False
Selection.Copy
Range("Q1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________

(\ /)
( . .)
C()() { 3 }
:=False, Transpose:=False

x = 0
Range("R101:AJ124").ClearContents
Range("C100:J100").Select
Selection.Copy
Range("C17:C40").Select
ActiveSheet.Paste
fac = Range("K12").Value
Sheets("LFAC").Select
ActiveSheet.Unprotect
Range("A2").Select
While ActiveCell.Value <> ""
If ActiveCell.Value = fac Then
x = 1
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("FMOD").Select
Range("R150").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("LFAC").Select
Selection.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
End If
ActiveCell.Offset(1, 0).Select
Wend
ActiveSheet.Protect

Sheets("TFAC").Select
ActiveSheet.Unprotect
Range("H2").Select
While ActiveCell.Value <> ""
If ActiveCell.Value = fac Then
ActiveCell.Offset(0, -7).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("FMOD").Select
Range("X101").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("TFAC").Select
Selection.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
End If
ActiveCell.Offset(1, 0).Select
Wend
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________

(\ /)
( . .)
C()() { 4 }
ActiveSheet.Protect

Sheets("FMOD").Select
Range("D11:H11").Select
ActiveCell.FormulaR1C1 = "=R[90]C[20]"
Range("K11").Select
ActiveCell.FormulaR1C1 = "=R[90]C[19]"
Range("M5").Select
ActiveCell.FormulaR1C1 = "=R[96]C[23]"
Range("D12").Select
ActiveCell.FormulaR1C1 = "=R[89]C[21]"
Range("D13").Select
ActiveCell.FormulaR1C1 = "=R[88]C[22]"
Range("F13").Select
ActiveCell.FormulaR1C1 = "=R[88]C[21]"
Range("H13").Select
ActiveCell.FormulaR1C1 = "=R[88]C[20]"
Range("D14").Select
ActiveCell.FormulaR1C1 = "=R[87]C[25]"
Range("AF101").Select
Selection.Copy
Range("J43").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

If x = 0 Then MsgBox prompt:="El nmero de factura no existe.",


Buttons:=vbOKOnly, Title:="ERROR"
Range("K12").Select
ActiveSheet.Protect

End Sub

Modulo 10
Sub fact_ingr_mod_guardar()
' Acceso directo: CTRL+k

Sheets("FMOD").Select
Application.ScreenUpdating = False
If Range("D11").Value = "" Then End
If Range("K11").Value = "" Then End
If Range("K12").Value = "" Then End
If Range("K12").Value <> Range("Q1").Value Then
MsgBox prompt:="ESTE NUMERO DE FACTURA NO ES EL QUE HABIA BUSCADO. SI
DESEA CREAR UNA FACTURA NUEVA VAYA AL APARTADO CORRESPONDIENTE.",
Buttons:=vbOKOnly, Title:="ERROR"
ActiveSheet.Protect
End If
If Range("K12").Value <> Range("Q1").Value Then End
x = 0
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________

(\ /)
( . .)
C()() { 5 }
fac = Range("K12").Value
ActiveSheet.Unprotect
Sheets("LFAC").Select
ActiveSheet.Unprotect
Range("A2").Select
While ActiveCell.Value <> ""
If ActiveCell.Value = fac Then x = 1
ActiveCell.Offset(1, 0).Select
Wend

If x = 0 Then
Sheets("FMOD").Select
Range("R17:V40").Select
Selection.Copy
Sheets("LFAC").Select
Range("A10002").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("C10002").Select
Selection.End(xlUp).Select
For a = 1 To 24
If ActiveCell.Value = 0 Then Selection.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
Next a
Range("A2:E10001").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Sheets("TFAC").Unprotect
Sheets("FMOD").Select
Range("X17:AJ17").Select
Selection.Copy
Sheets("TFAC").Select
Range("A10002").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A2:M10001").Select
Selection.Sort Key1:=Range("H2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect

Sheets("FMOD").Select
Range("D11:H11,D12,D13,F13,H13,D14,K11,K12,C17:J40,M5").Select
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________

(\ /)
( . .)
C()() { 6 }
Range("C17").Activate
Selection.ClearContents
MsgBox prompt:="Factura anotada.", Buttons:=vbOKOnly, Title:="ANOTADO"
End If
Sheets("LFAC").Protect
Sheets("FMOD").Select
If x = 1 Then MsgBox prompt:="El nmero de factura ya existe.",
Buttons:=vbOKOnly, Title:="ERROR"
Range("K12").Select
ActiveSheet.Protect

End Sub

Modulo 14
Sub est_ingr_pendiente()
' Acceso directo: CTRL+p

Sheets("EST").Select
ActiveSheet.Unprotect
Range("C16").Select
Selection.Interior.ColorIndex = 3
Application.ScreenUpdating = False

Sheets("CALCULO2").Unprotect
Sheets("TFAC").Select
Range("A2:M10001").Select
Selection.Copy
Sheets("CALCULO2").Select
Range("B9").Select
ActiveSheet.Paste
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "PENDIENTE DE COBRO"
Selection.Font.Bold = True
With Selection.Font
.Name = "Arial"
.Size = 14
End With
Range("B3:B6").ClearContents

Range("N9").Select
While ActiveCell.Value <> ""
If ActiveCell.Value <> "Pendiente" Then
Selection.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
End If
ActiveCell.Offset(1, 0).Select
Wend

tot = 0
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ __________________________

(\ /)
( . .)
C()() { 7 }
Range("K9").Select
While ActiveCell.Value <> ""
tot = tot + ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Wend
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = tot

tot = 0
Range("L9").Select
While ActiveCell.Value <> ""
tot = tot + ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Wend
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = tot

tot = 0
Range("M9").Select
While ActiveCell.Value <> ""
tot = tot + ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Wend
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = tot

ActiveSheet.Protect
Sheets("EST").Select
Range("C16").Select
Selection.Interior.ColorIndex = xlNone
ActiveSheet.Protect
Sheets("CALCULO2").Select
Range("A1").Select

End Sub

__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ________________________________

(\ /)
( . .)
C()() { 8 }

También podría gustarte