Documentos de Académico
Documentos de Profesional
Documentos de Cultura
'Copia
Origen.Activate
Origen.Range(Origen.Cells(6, 2), Origen.Cells(ULOrigen, 70)).Copy
'Pega
Destino.Activate
Destino.Cells(5, 1).PasteSpecial xlPasteAll
Destino.Cells(1, 1).Select
Hoja32.Activate
'Vacía
Set Origen = Nothing
Set Destino = Nothing
End Sub
End Sub
Public Sub EscribeTrazaLC(Cadena As String, ByVal L As Long, ByVal C As Integer) 'L es la línea y C
la columna
LineaTraza = LineaTraza + 1
Worksheets("Traza").Cells(LineaTraza, 1) = Cadena & " " & Replace(Cells(L, C).Address, "$", "")
& "."
End Sub
Public Sub ReseteaTraza()
LineaTraza = 0
Worksheets("Traza").Range("A1:IV" & Rows.Count).ClearContents
End Sub
Public Function NZ(Valor As Variant, Conversión As Variant) As Variant 'Convierte un vacío o un nul
l en un valor numérico
If Valor = "" Or IsNull(Valor) Or IsEmpty(Valor) Then
Funciones - 2
NZ = Conversión
Else
NZ = Valor
End If
End Function
'PROPIEDAD DE ALFREDO GOMEZ GRANDE 51669937T
'Œê¥î†]}Ö’Æf™¹½”Æ’w‘ålà™{™¤¼ˆµß’¨¹Ø}-¡©œÓ¹ÀƒÇ̃Æ[°Š ¨Ÿ§·ªÆÂÆÞ½§Ø¸ÃÝåÆëÀ¶ÁºÞ¾à
Globales - 1
Sub RevisarCuadres()
Dim Linea, Columna, TotLinea, LineaConfFact, LineaConfIVA As Long
Dim Debe, Haber, DebeSuma, HaberSuma As Currency
Dim OkRaiz, OkClaveIVA As Boolean
TotLinea = 6
Linea = 6
ReseteaContadores
EscribeTraza ("Revisión de asientos iniciada el " & Date & " " & Time)
Do Until Cells(Linea, 2).Value = "" 'BUCLE CAMBIA TIPO DE DATOS PARA LA ORDENACIÓN POSTERIOR
For Columna = 2 To 70
Select Case Columna 'Revisión tipos de datos y cambio del dato de las columnas de orden
ación.
Case 2, 4, 7 To 10, 15 To 19, 21, 25, 27, 39 To 43, 48 To 49, 53, 55, 57, 59, 6
1, 63, 65, 66, 68, 70 'Datos numéricos
End If
If Valor <> "" And Not IsDate(Valor) Then EscribeTraza "Valor no fecha en la lí
nea " & Cells(Linea, 2) + 6
End Select
Next Columna
Loop
'AQUÍ ORDENA
'Debe poner dentro del mismo asiento, las partidas al debe primero y luego las del Haber. IMPOR
TANTE REVISAR EL RANGO DE ORDENACIÓN SI SE AÑADEN NUEVOS CAMPOS <==================================
===========
OrdenarAsientos
Haber = 0
End If
Else 'Si el número de asiento no es numérico
EscribeTraza "Valor no numérico en la celda. Revisar línea " & Cells(Linea, 2) + 6
End If
End If
Loop
EscribeTraza ("Revisión de asientos terminada el " & Date & " " & Time)
Generación
End Sub
Call MsgBox("Vaya a la página ""Activación"" y siga los pasos que se describen para activarla. Grac
ias. ", vbCritical, "Aplicación no activada")
End Sub
Sub ReseteaContadores()
Cells(3, 2).Value = ""
Cells(3, 3).Value = ""
Cells(3, 4).Value = ""
End Sub
Case vbYes
Integrar
Case vbNo
MsgBox "Proceso cancelado", vbInformation, "Atención"
End Select
End Sub
'Sub OLDIntegrar()
'Dim ULOrigen, ULDestino As Long 'Ultimas líneas de origen y destino
'Dim Origen, Destino As Worksheet
Hoja28 - 4
Case vbYes
Case vbNo
MsgBox "Proceso cancelado", vbInformation, "Atención"
End Select
End Sub
Sub OrdenarAsientos()
End Sub
Hoja30 - 1
Call MsgBox("Vaya a la página ""Activación"" y siga los pasos que se describen para activarla.
Gracias. ", vbCritical, "Aplicación no activada")
End Sub
Case vbYes
Case vbNo
MsgBox "Proceso cancelado", vbInformation, "Atención"
End Select
End Sub
Hoja33 - 1
Sub RunFacturas()
Tot = 6
Lin = 7
LinD = 6
BorraDestino
TotLineas
ReseteaContador
ReseteaTraza
EscribeTraza "Generación de facturas lanzada el " & Date & " " & Time
Asiento = 1
Do Until Cells(Lin, 2) = "" 'CADA LINEA ES UNA FACTURA. CAMBIO DE LINEA = CAMBIO DE FACTURA = C
AMBIO DE ASIENTO
TipoFact = ""
TipoFact = EmitidaRecibida
'VALORES COMUNES
Comunes
'LINEA DEL TERCERO Asiento/Fecha/Cuenta/Concepto/Documento/Debe/Haber/BaseImp./TipoIVA/%RE/
Contrapartida/DepProyecto
Tercero
'LINEAS BASES IMPONIBLES. Si no hay cuenta, no escribe línea
Bases
'IVA
IVA
'Retenciones
Retencion1
Retencion2
Retencion3
Lin = Lin + 1
Asiento = Asiento + 1
Contador
Loop
EscribeTraza ("Generación de facturas terminada el " & Date & " " & Time)
End Sub
Sub Comunes()
Dim CC As Long
Destino.Cells(LinD, 2) = Asiento 'Asiento
Destino.Cells(LinD, 3) = Cells(Lin, 2) 'Fecha
Destino.Cells(LinD, 5) = Cells(Lin, 56) 'Concepto
Destino.Cells(LinD, 6) = Cells(Lin, 57) 'Documento
Destino.Cells(LinD, 22) = Cells(Lin, 67) 'Inmovilizado
Destino.Cells(LinD, 13) = Cells(Lin, 58) 'Proyecto
For CC = 82 To 87 'Segmentos
Hoja33 - 2
End Sub
Sub Retencion1()
Dim CR As Long
If Cells(Lin, 51) <> "" Then
Comunes
Destino.Cells(LinD, 4) = Cells(Lin, 51) 'Cuenta
Destino.Cells(LinD, 12) = Cells(Lin, 3) 'Contrapartida
If TipoFact = "E" Then Destino.Cells(LinD, 7) = Cells(Lin, 50) 'Importe
If TipoFact = "R" Then Destino.Cells(LinD, 8) = Cells(Lin, 50)
For CT = 62 To 66 'Moneda extranjera
Destino.Cells(LinD, CT - 45).Value = Cells(Lin, CT).Value
Next CT
LinD = LinD + 1
If Cells(Lin, 51) = "" Or Not IsNumeric(Cells(Lin, 51)) Then EscribeTraza "Falta la cue
nta del tercero o el dato no es numérico. Vea la línea " & Lin
If Cells(Lin, 50) = "" Or Not IsNumeric(Cells(Lin, 50)) Then EscribeTraza "Falta el imp
orte total de la factura o el dato no es numérico. Vea la línea " & Lin
End If
End Sub
Sub Retencion2()
Dim CR As Long
If Cells(Lin, 53) <> "" Then
Comunes
Destino.Cells(LinD, 4) = Cells(Lin, 53) 'Cuenta
Destino.Cells(LinD, 12) = Cells(Lin, 3) 'Contrapartida
If TipoFact = "E" Then Destino.Cells(LinD, 7) = Cells(Lin, 52) 'Importe
If TipoFact = "R" Then Destino.Cells(LinD, 8) = Cells(Lin, 52)
For CT = 62 To 66 'Moneda extranjera
Destino.Cells(LinD, CT - 45).Value = Cells(Lin, CT).Value
Next CT
LinD = LinD + 1
If Cells(Lin, 53) = "" Or Not IsNumeric(Cells(Lin, 53)) Then EscribeTraza "Falta la cue
nta del tercero o el dato no es numérico. Vea la línea " & Lin
If Cells(Lin, 52) = "" Or Not IsNumeric(Cells(Lin, 52)) Then EscribeTraza "Falta el imp
orte total de la factura o el dato no es numérico. Vea la línea " & Lin
End If
End Sub
Sub Retencion3()
Dim CR As Long
If Cells(Lin, 55) <> "" Then
Comunes
Destino.Cells(LinD, 4) = Cells(Lin, 55) 'Cuenta
Destino.Cells(LinD, 12) = Cells(Lin, 3) 'Contrapartida
If TipoFact = "E" Then Destino.Cells(LinD, 7) = Cells(Lin, 54) 'Importe
If TipoFact = "R" Then Destino.Cells(LinD, 8) = Cells(Lin, 54)
For CT = 62 To 66 'Moneda extranjera
Destino.Cells(LinD, CT - 45).Value = Cells(Lin, CT).Value
Next CT
LinD = LinD + 1
If Cells(Lin, 55) = "" Or Not IsNumeric(Cells(Lin, 55)) Then EscribeTraza "Falta la cue
Hoja33 - 3
nta del tercero o el dato no es numérico. Vea la línea " & Lin
If Cells(Lin, 54) = "" Or Not IsNumeric(Cells(Lin, 54)) Then EscribeTraza "Falta el imp
orte total de la factura o el dato no es numérico. Vea la línea " & Lin
End If
End Sub
Sub Bases() 'Hace un bucle. Si existe la cuenta procesa el resto del bloque
Dim CB As Long
For CB = 8 To 44
Select Case CB
Case 8, 17, 26, 35, 44
If Cells(Lin, CB) <> "" Then ' Procesa
Comunes
Destino.Cells(LinD, 4) = Cells(Lin, CB) 'Cuenta
Destino.Cells(LinD, 12) = Cells(Lin, 3) 'Contrapartida
If TipoFact = "E" Then Destino.Cells(LinD, 8) = Cells(Lin, CB - 3) 'Importe
If TipoFact = "R" Then Destino.Cells(LinD, 7) = Cells(Lin, CB - 3)
End Sub
Sub IVA()
Dim CI As Long
For CI = 9 To 46
Select Case CI
Case 9, 18, 27, 36, 45 'IVAS SOPORTADOS
If Cells(Lin, CI) <> "" Then ' Procesa
Comunes
Destino.Cells(LinD, 4) = Cells(Lin, CI) 'Cuenta
Destino.Cells(LinD, 7) = Cells(Lin, CI - 3) 'Importe. Un soportado siempre
estará en el Debe
Destino.Cells(LinD, 9) = Cells(Lin, CI - 4) 'Base
Destino.Cells(LinD, 10) = Cells(Lin, CI + 3) 'Tipo
ComunesIVA
ComunesIVA
End If
End If
End Select
Next CI
End Sub
Sub ComunesIVA()
Dim CCI As Long
For CCI = 68 To 81
Destino.Cells(LinD, CCI - 45).Value = Cells(Lin, CCI).Value
Next CCI
For CCI = 88 To 94
Destino.Cells(LinD, CCI - 45).Value = Cells(Lin, CCI).Value
Next CCI
LinD = LinD + 1
End Sub
Sub ReseteaContador()
Cells(3, 2) = ""
Cells(3, 3) = ""
Cells(3, 4) = ""
End Sub
Sub Contador()
Cells(3, 2) = Lin
Hoja33 - 5
End Sub
Function EmitidaRecibida() As String
Dim LicCF As Long
LinCF = 2
Do Until Worksheets("Config. Facturas").Cells(LinCF, 1) = ""
If Cells(Lin, 3) Like Worksheets("Config. Facturas").Cells(LinCF, 1).Value & "*" Then
EmitidaRecibida = Worksheets("Config. Facturas").Cells(LinCF, 2)
Exit Do
End If
LinCF = LinCF + 1
Loop
If EmitidaRecibida = "" Then EscribeTrazaLC "No se ha encontrado la raiz de la cuenta ' " & Cel
ls(Lin, 3) & " ' en la hoja 'Config. Facturas'. Revise la celda ", Lin, 3
End Function
Function CuentaIVA(Cuenta As String) As Boolean
Dim L As Long 'Línea de la hoja de configuración de IVA
End Function
Sub TotLineas()
Do Until Cells(Tot, 2).Value = ""
Tot = Tot + 1
Loop
End Sub
Case vbYes
Case vbNo
MsgBox "Proceso cancelado", vbInformation, "Atención"
End Select
End Sub
Hoja34 - 1
Sub RunExtracto()
Lin = 7
LinD = 6
Asiento = 1
BorraDestino
ReseteaContador
ReseteaTraza
EscribeTraza "Generación de extracto lanzada el " & Date & " " & Time
If Not IsNumeric(Cells(3, 4)) Or Cells(3, 4) = "" Then EscribeTrazaLC "Falta la cuenta del banc
o o el dato no es numérico. Vea la celda ", 3, 4
EscribeTraza ("Generación de extracto terminada el " & Date & " " & Time)
Hoja28.RevisarCuadres 'Lanza el proceso
MsgBox "Generación de Extracto terminado. Revise la hoja 'Traza'.", vbInformation, "Atención"
ReseteaContador
Integrar
End Sub
Sub PrimeraLinea()
Comunes
Destino.Cells(LinD, 4) = Cells(Lin, 4) 'Cuenta del tercero
If Cells(Lin, 3) > 0 Then 'Estamos en la línea del tercero, así que si es un cobro (positivo),
irá en el Haber
Destino.Cells(LinD, 8) = Cells(Lin, 3)
Else
Destino.Cells(LinD, 7) = Cells(Lin, 3) * -1
End If
LinD = LinD + 1
If Not IsDate(Cells(Lin, 2)) Then EscribeTrazaLC "Falta la fecha del movimiento o el dato no es
una fecha. Vea la celda ", Lin, 2
If Not IsNumeric(Cells(Lin, 3)) Or Cells(Lin, 3) = "" Then EscribeTrazaLC "Falta el importe del
movimiento o el dato no es numérico. Vea la celda ", Lin, 3
If Not IsNumeric(Cells(Lin, 4)) Or Cells(Lin, 4) = "" Then EscribeTrazaLC "Falta la cuenta del
movimiento o el dato no es numérico. Vea la celda ", Lin, 4
End Sub
Sub SegundaLinea()
Comunes
Destino.Cells(LinD, 4) = Cells(3, 4) 'Cuenta del banco
If Cells(Lin, 3) > 0 Then 'Estamos en la línea del banco, así que si es un cobro (positivo), ir
á en el Debe
Destino.Cells(LinD, 7) = Cells(Lin, 3)
Else
Destino.Cells(LinD, 8) = Cells(Lin, 3) * -1
End If
LinD = LinD + 1
Hoja34 - 2
End Sub
Sub Comunes()
Dim CC As Long
For CC = 13 To 14 'Segmentos
Destino.Cells(LinD, CC + 24) = Cells(Lin, CC)
Next CC
End Sub
Sub ReseteaContador()
Cells(3, 2) = ""
Cells(3, 3) = ""
End Sub
Sub Contador()
Cells(3, 2) = Lin
End Sub
Sub BorraDestino()
Hoja28.Range("A6:IV" & Rows.Count).ClearContents
Hoja29.Range("A1:IV" & Rows.Count).ClearContents
Hoja36.Range("A5:IV" & Rows.Count).ClearContents
End Sub
Case vbYes
Case vbNo
MsgBox "Proceso cancelado", vbInformation, "Atención"
End Select
End Sub
Shrink - 1
Option Explicit
Sub SHRINK_EXCEL_FILE_SIZE()
WSheet.Activate
'Put the sheets in a variable to make it easy to go back and forth
CSheet = WSheet.Name
'Find the bottom cell of data on each column and find the further row
For Col = 1 To Columns.Count 'Find the actual last bottom row
If Cells(Rows.Count, Col).End(xlUp).Row > BRow Then
BRow = Cells(Rows.Count, Col).End(xlUp).Row
End If
Next
Debug.Print BRow
'Find the end cell of data on each row that has data and find the furthest one
For lRow = 1 To BRow 'Find the actual last right column
If Cells(lRow, Columns.Count).End(xlToLeft).Column > ECol Then
ECol = Cells(lRow, Columns.Count).End(xlToLeft).Column
End If
Next
Debug.Print ECol
Sheets(OSheet).Activate
Sheets(CSheet).Activate
ECol = 0
Next WSheet
' Since, Excel will automatically replace the sheet references for you on your formulas,
' the below part puts them back.
' This is done with a simple replace, replacing _Delete with nothing
For Each WSheet In Worksheets
WSheet.Activate
Cells.Replace "_Delete", ""
Next WSheet
'Roll through the sheets and delete the original fat sheets
For Each WSheet In Worksheets
If Not Len(Replace(WSheet.Name, "_Delete", "")) = Len(WSheet.Name) Then
Application.DisplayAlerts = False
WSheet.Delete
Application.DisplayAlerts = True
End If
Next
End Sub
ThisWorkbook - 1
UserForm1.Show
End Sub
UserForm1 - 1
End Sub
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Label7_Click
' Author : ALFREDO
' Date : 06/08/2010
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub Label7_Click()
End Sub