facturas avanzadas final visual basic

37
Formfacturados - 1 Private Sub ComboBox1_Change() ComboBox2.Clear ruta = ThisWorkbook.Path & "\Facturados\" LIBRO = Formfacturados.ComboBox1 Workbooks.Open Filename:=ruta & LIBRO Workbooks(LIBRO).Activate Sheets("Hoja1").Select Range("K2").Select Do While Not IsEmpty(ActiveCell) If Left(ActiveCell, 5) <> "Total" Then If InStr(factrs, ActiveCell) = 0 Then factrs = factrs & "," & ActiveCell End If End If ActiveCell.Offset(1, 0).Select Loop factrs = Right(factrs, Len(factrs) - 1) num_factrs = Split(factrs, ",") For I = 0 To UBound(num_factrs) ComboBox2.AddItem num_factrs(I) Next End Sub Private Sub ComboBox1_Enter() Application.ScreenUpdating = False On Error Resume Next Sheets("Hoja1").Activate Range("AA3").Select Do While Not IsEmpty(ActiveCell) ComboBox1.AddItem ActiveCell ActiveCell.Offset(1, 0).Select Loop End Sub Private Sub ComboBox2_Change() Formfacturados.Hide End Sub

Upload: diana-elizabeth-llovera-villanueva

Post on 22-Nov-2015

38 views

Category:

Documents


6 download

TRANSCRIPT

  • Formfacturados - 1

    Private Sub ComboBox1_Change() ComboBox2.Clear ruta = ThisWorkbook.Path & "\Facturados\" LIBRO = Formfacturados.ComboBox1

    Workbooks.Open Filename:=ruta & LIBRO Workbooks(LIBRO).Activate Sheets("Hoja1").Select Range("K2").Select Do While Not IsEmpty(ActiveCell) If Left(ActiveCell, 5) "Total" Then If InStr(factrs, ActiveCell) = 0 Then factrs = factrs & "," & ActiveCell End If End If ActiveCell.Offset(1, 0).Select Loop factrs = Right(factrs, Len(factrs) - 1) num_factrs = Split(factrs, ",") For I = 0 To UBound(num_factrs) ComboBox2.AddItem num_factrs(I) Next End Sub Private Sub ComboBox1_Enter() Application.ScreenUpdating = False On Error Resume Next Sheets("Hoja1").Activate Range("AA3").Select Do While Not IsEmpty(ActiveCell) ComboBox1.AddItem ActiveCell ActiveCell.Offset(1, 0).Select Loop

    End Sub

    Private Sub ComboBox2_Change()Formfacturados.HideEnd Sub

  • Hoja1 - 1 Private Sub CommandButton1_Click()IR_A_INICIOEnd Sub

    Hoja4 - 1 Private Sub CommandButton1_Click()IR_A_INICIOEnd Sub

    Hoja6 - 2 lanza_facturables_albaran End If If Range("g7") = "" Then Range("g7").Value = "Click para rellenar" Range("G7").Interior.Color = &H80FF80 Else Range("G7").Interior.Color = vbWhite End If If Not Application.Intersect(Target, Range("G7")) Is Nothing Then UserForm9.Show End If Sheets("Albaran").Select End Sub

    Hoja7 - 2 .ForeColor = vbWhite .BackColor = vbBlueEnd WithWith Label3 .ForeColor = vbWhite .BackColor = vbBlueEnd With

    End Sub

  • Hoja11 - 1 Private Sub CommandButton1_Click()

    Range("G6:G10").ClearContents Range("D6:D10").ClearContents Range("B14:F36").ClearContents Range("G4").Select End Sub

    Private Sub CommandButton2_Click()IR_A_INICIOEnd Sub

    Private Sub Worksheet_Activate()ScrollArea = "a1:h44"End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Range("g7") = "" Then Range("g7").Value = "Click para rellenar" Range("G7").Interior.Color = &H80FF80 Else Range("G7").Interior.Color = vbWhite End If

    If Not Application.Intersect(Target, Range("B14:B36")) Is Nothing Then lanza_facturables_presupuesto End If

    If Not Application.Intersect(Target, Range("G7")) Is Nothing Then UserForm7.Show End If

    Sheets("Presupuesto (2)").Activate

    End Sub

  • Hoja5 - 1 Private Sub Label1_Click()With Label1 .ForeColor = vbWhite .BackColor = vbBlueEnd WithIR_A_INICIOEnd Sub

    Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With Label1 .ForeColor = vbBlack .BackColor = vbCyanEnd WithEnd Sub

    Private Sub Label2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With Label1 .ForeColor = vbWhite .BackColor = vbBlueEnd WithWith Label3 .ForeColor = vbWhite .BackColor = vbBlueEnd With

    End Sub

    Private Sub Label3_Click()With Label1 .ForeColor = vbWhite .BackColor = vbBlueEnd WithFACTURALCLIENTE

    End Sub

    Private Sub Label3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With Label3 .ForeColor = vbBlack .BackColor = vbCyanEnd WithEnd Sub

  • Hoja6 - 1 Private Sub CommandButton1_Click()IR_A_INICIOEnd Sub

    Private Sub CommandButton2_Click()BorrarAlbarancondowhileEnd Sub

    Private Sub Label1_Click()If Range("F4") = "A" Then GeneralbaranElse GenerafactinmediataEnd IfEnd Sub

    Private Sub Label2_Click()UserForm8.ShowSheets("Albaran").ActivateEnd Sub

    Private Sub ToggleButton1_Click()Application.ScreenUpdating = FalseWith ToggleButton1 If .Value = True Then .Picture = LoadPicture("C:\Users\Miguel\Pictures\Plantillas y recursos\BOTONES\ambar.jpg") .ForeColor = vbWhite Range("B2") = "Factura" Range("E3") = "N Factura" Range("E54") = "Suma Factura" Rows("55:56").EntireRow.Hidden = False Label1.Caption = "GENERAR FACTURA"Else .Picture = LoadPicture("C:\Users\Miguel\Pictures\Plantillas y recursos\BOTONES\platteado.gif") .ForeColor = vbBlack Range("B2") = "Albarn" Range("E3") = "N Albarn" Range("E54") = "Suma Albarn" Rows("55:56").EntireRow.Hidden = True Label1.Caption = "GENERAR ALBARAN" End IfEnd WithApplication.ScreenUpdating = True

    End Sub

    Private Sub Worksheet_Activate()ScrollArea = "a1:h69"End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Not Application.Intersect(Target, Range("B14:B36")) Is Nothing Then

  • Hoja7 - 1 Private Sub Label1_Click()With Label1 .ForeColor = vbWhite .BackColor = vbBlueEnd WithIR_A_INICIOEnd Sub

    Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With Label1 .ForeColor = vbBlack .BackColor = &H80FFFFEnd WithEnd Sub

    Private Sub Label2_Click()With Label2 .ForeColor = vbWhite .BackColor = vbBlueEnd WithImprimefacturasEnd Sub

    Private Sub Label2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With Label2 .ForeColor = vbBlack .BackColor = &H80FFFFEnd WithEnd Sub

    Private Sub Label3_Click()With Label3 .ForeColor = vbWhite .BackColor = vbBlueEnd WithCopia_SubtotalesEnd Sub

    Private Sub Label3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With Label3 .ForeColor = vbBlack .BackColor = &H80FFFFEnd WithEnd Sub

    Private Sub Label4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With Label1 .ForeColor = vbWhite .BackColor = vbBlueEnd WithWith Label2

  • Macros_Almacen - 1

    Sub IR_A_INICIO()Sheets("INICIO").ActivateEnd Sub

    Sub IR_A_ALBARAN()Sheets("Albaran").ActivateEnd Sub

    Sub IR_A_FACT()Sheets("Facturacion").ActivateEnd Sub

    Sub IR_A_FACTEMIT()Sheets("Facturas emitidas").ActivateEnd Sub

    Sub Muestra_User8()UserForm8.ShowEnd Sub

    Sub mUESTRAuSER1()UserForm1.ShowEnd Sub

    Sub actualiza_existencias()Application.ScreenUpdating = False

    marca = UserForm5.ComboBox1LIBRO = UserForm5.ComboBox2ruta = ThisWorkbook.Path & "\Pedidos Recibidos\" If marca = "El Pato" Then cabecera = "modelo" ElseIf marca = "MCA" Then cabecera = "Ref#" ElseIf marca = "MRC" Then cabecera = "modelo" Else: marca = "MRK" cabecera = "modelo" End If Workbooks.Open Filename:=ruta & LIBRO Workbooks(LIBRO).Activate Sheets("Hoja1").Activate Cells.Find(What:=cabecera, LookAt:=xlWhole).Activate ActiveCell.Offset(1, 0).Select Do While ActiveCell "" modelo = ActiveCell If marca = "El Pato" Then cantidad = ActiveCell.Offset(0, 2) ElseIf marca = "MCA" Then cantidad = ActiveCell.Offset(0, 3)

  • Macros_Almacen - 2 ElseIf marca = "MRC" Then cantidad = ActiveCell.Offset(0, 2) Else: marca = "MRK" cantidad = ActiveCell.Offset(0, 2) End If ThisWorkbook.Activate Sheets(marca).Select Range("A2").Select Cells.Find(What:=modelo, LookAt:=xlWhole).Activate ActiveCell.Offset(0, 3).Value = ActiveCell.Offset(0, 3).Value + cantidad Workbooks(LIBRO).Activate Sheets("Hoja1").Select ActiveCell.Offset(1, 0).SelectLoop ThisWorkbook.Activate Sheets(marca).Select Workbooks(LIBRO).Close End Sub

    Sub generar_pedido()'desactiva refresco pantallaApplication.ScreenUpdating = False

    'establecemos valor de variable marca = UserForm5.ComboBox1 'buscamos marca Sheets("Hoja1").Activate Range("L1:M15").Find(What:=marca, LookAt:=xlWhole).Activate 'establecemos valor de variable con formato npedido = Application.WorksheetFunction.Text(ActiveCell.Offset(2, 0) + 1, "0000")

    'actualizamos registro de pedidos ActiveCell.Offset(2, 0).Value = ActiveCell.Offset(2, 0).Value + 1 With ActiveCell.Offset(2, 1) .Formula = "=TEXT(TODAY(),""dd-mmm-aa"")" .Copy .PasteSpecial xlPasteValuesEnd With

    'establecemos valor de variablesnombre_pedido = "PEDIDO " & marca & "-" & npedido & ".xlsx"plantilla = ThisWorkbook.Path & "\Mis Plantillas Excel\"ruta = ThisWorkbook.Path & "\Pedidos a Proveedor\"

    Sheets("PROVEEDORES").ActivateRange("A1").Select

  • Macros_Almacen - 3 Cells.Find(What:=marca, LookAt:=xlWhole).Select

    Set nombre = ActiveCellSet nif = ActiveCell.Offset(0, 1)Set direc = ActiveCell.Offset(0, 2)Set pobla = ActiveCell.Offset(0, 3)Set prov = ActiveCell.Offset(0, 4)Set cp = ActiveCell.Offset(0, 5)Set tel = ActiveCell.Offset(0, 6)Set emil = ActiveCell.Offset(0, 7)Set contacto = ActiveCell.Offset(0, 9)Set pais = ActiveCell.Offset(0, 10)

    'creamos pedido a partir de plantilla y lo renombramosWorkbooks.Add Template:=plantilla & "PEDIDO.xltx"ActiveWorkbook.SaveAs Filename:=ruta & nombre_pedido, _ FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False 'ponemos direccin del proveedor en el encabezadoWith ActiveSheet .PageSetup.RightHeader = "&14" & "&B" & marca & Chr(13) & "&B" & "&12" & direc & Chr(13) & cp & " " & pobla & _ Chr(13) & prov & Chr(13) & pais & Chr(13) & "&10" & emil & Chr(13) & Chr(13) & "Atencin: " & "&U" & contacto 'ponemos la fecha del pedido y el nmero With Range("B1") .Formula = "=today()" .Copy .PasteSpecial xlPasteValues End With Range("B2") = "PEDIDO " & marca & "-" & npedidoEnd With

    'filtramos los datos segn cantidadThisWorkbook.Activate Sheets(marca).Activate Range("D1").Copy Range("M1") Range("M2") = "

  • Macros_Almacen - 4 End If 'quitamos la columna precioColumns("Q:Q").Delete

    'Calculamos les cantidades a pedirRange("Q2").SelectDo While ActiveCell "" ActiveCell.Value = 10 - ActiveCell.Value ActiveCell.Offset(1, 0).Select Loop 'copiamos los datosRange("O2").SelectRange(Selection, Selection.End(xlToRight)).SelectIf Range("O3") "" Then Range(Selection, Selection.End(xlDown)).SelectEnd If

    Selection.Copy 'los pegamos en el pedido Workbooks(nombre_pedido).Activate Range("A5").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False 'borramos el filtro temporal ThisWorkbook.Activate Columns("M:Q").Delete Range("A1").Activate 'activamos el pedido terminado para enviarlo Workbooks(nombre_pedido).Activate Range("A1").Activate Application.CutCopyMode = False

    End Sub

    Sub lanza_facturables_alta_items() Unload UserForm1 With Rellenar_facturables .CommandACEPTARP.Visible = False .CommandACEPTARA.Visible = False .LabePrecio.Visible = False .TextBoxCANTIDAD.Visible = False .TextBoxPRECIO.Visible = False .BotonCancelar.Visible = False .Label1.Caption = "AADIR ELEMENTOS" .Show End With

    End Sub

    Sub lanza_actualiza_existencias() With UserForm5

  • Macros_Almacen - 5 .CommandButton1.Visible = False .Label1.Caption = "Que marca va a actualizar" .BackColor = &H4000& .Show End WithEnd Sub

    Sub lanza_generar_pedido() With UserForm5 .CommandButton2.Visible = False .ComboBox2.Visible = False .CommandButton1.Top = 84 .Height = 159 .Label1.Caption = "Elegir marca" .Show End WithEnd Sub

    Sub registro_de_pedidos()

    On Error Resume NextApplication.ScreenUpdating = False

    Set fso = CreateObject("Scripting.FileSystemObject")ruta = ThisWorkbook.Path & "\Pedidos a Proveedor\"Set carpeta = fso.GetFolder(ruta)Set pedidos = carpeta.Files

    Sheets("Hoja1").ActivateRange("P3").Select

    For Each archivo In pedidosActiveCell = archivo.NameActiveCell.Offset(0, 1) = FormatDateTime(archivo.DateCreated, vbShortDate)ActiveCell.Offset(1, 0).SelectNext

    Set fso = NothingSet carpeta = NothingSet pedidos = Nothing

    Application.ScreenUpdating = TrueEnd Sub

    Sub BorrarAlbarancondowhile()

    Application.ScreenUpdating = FalseSheets("Albaran").SelectRange("C14").Activate

    If Range("C14") = "" Then GoTo borranombreEnd If

    Do While ActiveCell "" hoja = ActiveCell.Offset(0, -1)

  • Macros_Almacen - 6 modelo = ActiveCell cantidad = ActiveCell.Offset(0, 2) Sheets(hoja).Select Range("A1").Select Cells.Find(What:=modelo, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate ActiveCell.Offset(0, 3).Value = ActiveCell.Offset(0, 3).Value + cantidad Sheets("Albaran").Select ActiveCell.Offset(1, 0).Select Loop Range("B14:F52").ClearContents borranombre: Range("G5:G11").ClearContents Range("A1").ActivateEnd Sub

    Sub proveedor_pedido()Application.ScreenUpdating = False

    Set fso = CreateObject("Scripting.FileSystemObject")ruta = ThisWorkbook.Path & "\Pedidos Recibidos\"Set carpeta = fso.GetFolder(ruta)Set pedidos = carpeta.Files

    Sheets("Hoja1").ActivateRange("v3").Select

    For Each archivo In pedidosActiveCell = archivo.NameActiveCell.Offset(0, 1) = FormatDateTime(archivo.DateCreated, vbShortDate)ActiveCell.Offset(1, 0).SelectNext

    Set fso = NothingSet carpeta = NothingSet pedidos = Nothing

    End Sub

  • Macros_antiguas - 1

    Sub DatosCuadro4()'PASA DATOS DE FACTURA Y CLIENTE A HOJA 1 PARA EL CUADRO 4 Application.ScreenUpdating = False With Sheets("Hoja1") .Range("A2:C1000").ClearContents End With Sheets("Facturas Emitidas").Activate Range("J2").Select Range(Selection, Selection.End(xlToRight)).Select If Range("J3") "" Then Range(Selection, Selection.End(xlDown)).Select End If Selection.Copy Sheets("Hoja1").Activate Range("A2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Sheets("Facturas Emitidas").Activate Range("D2").Select If Range("D3") "" Then Range(Selection, Selection.End(xlDown)).Select End If Selection.Copy

    Sheets("Hoja1").Activate Range("C2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("A2").Activate Application.CutCopyMode = False

    End Sub

    Sub FiltraCuadro4()'FILTRA FACTURAS UNICAS PARA CUADRO 4 Application.CutCopyMode = False Columns("A:C").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _ "E1:E2"), CopyToRange:=Range("G1:I1"), Unique:=True Application.CutCopyMode = False Sheets("Facturas Emitidas").Activate End Sub

    Sub FACTURALCLIENTE()UserForm3.ShowUserForm2.ShowEnd Sub

  • Macros_nuevas - 1 Sub FACTURAYA() 'MUEVE DATOS A FACTURAS EMITIDAS

    Application.ScreenUpdating = False UserForm2.Hide 'Filtramos por cliente Columns("A:J").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range _ ("M1:N2"), Unique:=False 'Localizamos el cliente para hacer la seleccin Cells.Find(What:=Range("M2"), After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate ' Escondemos los encabezados para seleccionar la regin con los datos Rows("1:1").Hidden = True Selection.CurrentRegion.Select Selection.Copy 'vamos a la otra hoja Sheets("Facturas Emitidas").Activate Range("A1").Activate ' buscamos la 1 fila vaca Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ' copiamos los datos y n de factura ActiveSheet.Paste Application.CutCopyMode = False ' vuelta a Facturacion y borrado de datos copiados Sheets("Facturacion").Activate Selection.Delete Shift:=xlUp 'mostramos los encabezados y quitamos el filtro Range("A1").Activate Selection.EntireRow.Hidden = False ActiveSheet.ShowAllData Application.CutCopyMode = False Range("A1").Select Call n_fac_fijo Call fecha_factura End Sub

    Sub MuestraUser7()UserForm7.ShowSheets("Presupuesto").ActivateEnd Sub

  • Macros_nuevas - 2

    Sub MuestraUser8()UserForm8.ShowSheets("Presupuesto (2)").ActivateEnd Sub

    Sub RELLENENOMBREALBARAN()

    Application.ScreenUpdating = False Set fila = Cells(1, 1) Sheets("Lista de Clientes").Select Cells(fila + 1, 2).Select Set varNOMBRE = ActiveCell Set varNIF = ActiveCell.Offset(0, -1) Set varDIRECCION = ActiveCell.Offset(0, 1) Set varCP = ActiveCell.Offset(0, 3) Set varTELEF = ActiveCell.Offset(0, 2) Set varEMAIL = ActiveCell.Offset(0, 4) Set varNUMCLI = ActiveCell.Offset(0, 5) Sheets("Albaran").Select Range("G7") = varNOMBRE Range("G6") = varNIF Range("G9") = varDIRECCION Range("G10") = CDbl(varCP) Range("G11") = CDbl(varTELEF) Range("G8") = varEMAIL Range("G5") = varNUMCLI End Sub

    Sub Generalbaran() 'Pasa el albarn a Facturacin Application.ScreenUpdating = False

    If Range("G7") = 0 Then MsgBox ("INTRODUCIR UN CLIENTE") End ElseIf Range("B14") = 0 Or Range("E14") = 0 Then MsgBox ("LA REFERENCIA O LA CANTIDAD NO PUEDE SER NULA") End ElseIf MsgBox("DESEA IMPRIMIR EL ALBARAN?", vbQuestion + vbYesNo) = vbYes Then IMPRIMIR End If Range("A1").Value = Range("A1").Value + 1 If Range("A1").Value > 9999 Then Range("A1").Value = 1 End If 'definimos variables para los campos Set varFECHA = Range("G2")

  • Macros_nuevas - 3 Set varNUMALB = Range("G3") Set varNOMBRE = Range("G7") Set varNIF = Range("G6") Set varID = Range("F4") Set items = Range("C54") ' copiamos los artculos del albarn Range("C14").Select If Range("C15") "" Then Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Else Range(Selection, Selection.End(xlToRight)).Select End If Selection.Copy ' los llevamos a Facturacin Sheets("Facturacion").Select ' buscamos la 1 celda vaca del artculo Cells(1, 5).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop' pegamos los datos ActiveCell.PasteSpecial xlPasteValuesAndNumberFormats Application.CutCopyMode = False Cells(1, 1).Select' buscamos la 1 celda vaca de los datos del cliente' y volcamos las variables con sus datos, tantas veces como filas hay en el albarn For I = 1 To items Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell = varNUMALB ActiveCell.Offset(0, 1) = CDate(varFECHA) ActiveCell.Offset(0, 2) = varNIF ActiveCell.Offset(0, 3) = varNOMBRE ActiveCell.Offset(0, 9) = CStr(varID) Next I ' volvemos a la hoja albarn y borramos todo Sheets("Albaran").Select Range("G5:G11").ClearContents Range("B14:F52").ClearContents Range("A1").Select End Sub

    Sub Generafactinmediata()Application.ScreenUpdating = False

    If Range("G7") = 0 Then

  • Macros_nuevas - 4 MsgBox ("INTRODUCIR UN CLIENTE") End ElseIf Range("B14") = 0 Or Range("E14") = 0 Then MsgBox ("LA REFERENCIA O LA CANTIDAD NO PUEDE SER NULA") End ElseIf MsgBox("DESEA IMPRIMIR LA FACTURA?", vbQuestion + vbYesNo) = vbYes Then IMPRIMIR End If Range("A1").Value = Range("A1").Value + 1

    'definimos variables para los campos Set varFECHA = Range("G2") Set varNUMFACT = Range("G3") Set varNOMBRE = Range("G7") Set varNIF = Range("G6") Set varID = Range("F4") Set items = Range("C54") ' copiamos los artculos del albarn Range("C14").Select If Range("C15") "" Then Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Else Range(Selection, Selection.End(xlToRight)).Select End If Selection.Copy ' los llevamos a Facturas Emitidas Sheets("Facturas Emitidas").Select ' buscamos la 1 celda vaca del artculo Cells(1, 5).Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop' pegamos los datos ActiveCell.PasteSpecial xlPasteValuesAndNumberFormats Application.CutCopyMode = False ' buscamos la 1 celda vaca de los datos del cliente' y volcamos las variables con sus datos, tantas veces como filas hay en el albarn Cells(1, 1).Select For I = 1 To items Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell = varNUMFACT ActiveCell.Offset(0, 1) = CDate(varFECHA) ActiveCell.Offset(0, 2) = varNIF ActiveCell.Offset(0, 3) = varNOMBRE ActiveCell.Offset(0, 9) = CStr(varID)

  • Macros_nuevas - 5 Next I 'asignamos n factura y fecha Call n_fac_fijo Call fecha_factura ' volvemos a la hoja albarn y borramos todo Sheets("Albaran").Select Range("G5:G11").ClearContents Range("B14:F52").ClearContents Range("A1").Select

    End Sub

    Sub IMPRIMIR() 'IMPRIME DOCUMENTO EN IMPRESORA PREDEFINIDA ActiveWindow.ActiveSheet.PrintOut Copies:=1, IgnorePrintAreas:=FalseEnd Sub

    Sub lanza_facturables_albaran() With Rellenar_facturables .CommandACEPTARP.Visible = False .BotonANADIRLEMENTO.Visible = False .TextBoxCantAnadir.Visible = False .LabelANADIR.Visible = False .CommandButtonC.Visible = False .Label1.Caption = "ELEGIR UN EQUIPO" .Show End WithEnd Sub

    Sub lanza_facturables_presupuesto() With Rellenar_facturables .CommandACEPTARA.Visible = False .BotonANADIRLEMENTO.Visible = False .TextBoxCantAnadir.Visible = False .LabelANADIR.Visible = False .CommandButtonC.Visible = False .Label1.Caption = "ELEGIR UN EQUIPO" .Show End WithEnd SubSub Imprimefacturas()Application.ScreenUpdating = FalseOn Error Resume Next

    With Sheets("Hoja3").Range("B7:H1000") .ClearContents .Borders.LineStyle = xlNoneEnd With

    Call DatosCuadro4 Call FiltraCuadro4 UserForm4.Show UserForm4.ComboBox1 = Range("N2") Sheets("Facturas Emitidas").Activate

  • Macros_nuevas - 6 Range("A1").Select Columns("A:L").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _ "N1:O2"), CopyToRange:=Range("R1:AC1"), Unique:=False Range("R2:S2").Select If Range("R3") "" Then Range(Selection, Selection.End(xlDown)).Select End If Selection.Copy

    Sheets("Hoja3").Select Range("B7").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Sheets("Facturas Emitidas").Select Set cliente = Range("U2") Set FECHA_FCTRA = Range("AC2") Range("V2:Z2").Select If Range("R3") "" Then Range(Selection, Selection.End(xlDown)).Select End If Selection.Copy

    Sheets("Hoja3").Select Range("D7").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("D4") = FECHA_FCTRA Range("H7").Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop Set varSuma = Range(Cells(7, 8), ActiveCell) suma = Application.WorksheetFunction.Sum(varSuma) iva = suma * 0.18 Total = suma + iva fsuma = Format(suma, "#,##0.00 ") fiva = Format(iva, "#,##0.00 ") fTotal = Format(Total, "#,##0.00 ")

    ActiveCell.Offset(1, 0).Select Call AreaImpresion Sheets("Lista de clientes").ActivateRange("A1").SelectCells.Find(What:=cliente, LookAt:=xlWhole).SelectSet direc = ActiveCell.Offset(0, 1)Set cp = ActiveCell.Offset(0, 3)

  • Macros_nuevas - 7

    Sheets("Hoja3").ActivateWith ActiveSheet.PageSetup .RightHeader = Chr(13) & Chr(13) & "&14 &B" & cliente & "&B" & _Chr(13) & "&12" & direc & Chr(13) & cp & " Madrid" & Chr(13) & "Espaa" .RightFooter = "&B &USuma= " & fsuma & Chr(13) & "IVA= " & fiva _ & Chr(13) & "Total= " & fTotal & Chr(13) & Chr(13)End With

    End Sub

    Sub AreaImpresion()

    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Activate With ActiveCell.Offset(2, 0) celda = .Address End With ActiveSheet.PageSetup.PrintArea = "$B$1:" & celdaEnd Sub

    Sub n_fac_fijo()

    Application.ScreenUpdating = False

    Sheets("Facturas Emitidas").Activate Range("AE1").Copy Range("J1").Select Selection.End(xlDown).Select ActiveCell.Offset(0, 1).Select Range(Selection, Selection.End(xlUp)).Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Selection.End(xlDown).Select

    End SubSub fecha_factura() Sheets("Facturas Emitidas").Activate Range("J1").Select Selection.End(xlDown).Select ActiveCell.Offset(0, 2).Select Range(Selection, Selection.End(xlUp)).Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.FormulaR1C1 = "=TODAY()" Selection.Copy Selection.PasteSpecial xlPasteValues Application.CutCopyMode = False Selection.End(xlDown).Select

  • Macros_nuevas - 8 End Sub

    Sub facturatodos() UserForm2.Hide Range("A2").Select Range(Selection, Selection.End(xlToRight)).Select If Range("A3") "" Then Range(Selection, Selection.End(xlDown)).Select End If

    Selection.Copy With Sheets("Facturas Emitidas") .Activate .Range("A2").Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop Selection.PasteSpecial Paste:=xlPasteValues, Operation:= _ xlNone, SkipBlanks:=False, Transpose:=False

    End With Application.CutCopyMode = False

    Call n_fac_fijo Call fecha_factura

    Sheets("Facturacion").Activate Selection.ClearContents Range("A1").Select End Sub

  • Macros_volcado - 1 Sub Copia_Subtotales()Application.ScreenUpdating = False Sheets("Facturas Emitidas").Activate

    ruta = ThisWorkbook.Path & "\Facturados\"ahora = Application.WorksheetFunction.Text(Now(), "dd.mm.yy- hh.mm")LIBRO = "Facturacin totalizada" & " " & ahora & ".xlsx"

    Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy Workbooks.Add ActiveSheet.Paste ActiveWorkbook.SaveAs Filename:=ruta & LIBRO, _ FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False Range("A1").Select Application.CutCopyMode = False Selection.Subtotal GroupBy:=11, Function:=xlSum, TotalList:=Array(9), _ Replace:=True, PageBreaks:=False, SummaryBelowData:=True On Error Resume Next Range("K2").Select Do While ActiveCell "" If ActiveCell >= "Total F" Then

    ActiveCell.Offset(0, -4).Value = ActiveCell.Offset(0, -2).Value * 1.18 ActiveCell.Offset(0, -4).NumberFormat = _ "_-* #,##0.00 [$-C0A]_-;-* #,##0.00 [$-C0A]_-;_-* ""-""?? [$-C0A]_-;_-@_-" ActiveCell.Offset(0, -5) = "Total con IVA: " ActiveCell.Offset(0, -5).HorizontalAlignment = xlRight ActiveCell.Offset(0, -7).Value = ActiveCell.Offset(0, -2).Value * 0.18 ActiveCell.Offset(0, -7).NumberFormat = _ "_-* #,##0.00 [$-C0A]_-;-* #,##0.00 [$-C0A]_-;_-* ""-""?? [$-C0A]_-;_-@_-" ActiveCell.Offset(0, -8) = "IVA 18% " ActiveCell.Offset(0, -8).HorizontalAlignment = xlRight End If

    ActiveCell.Offset(1, 0).Select Loop Columns("A:L").EntireColumn.AutoFit Application.CutCopyMode = False

  • Macros_volcado - 2 End SubSub Lista_volcados()

    Set fso = CreateObject("Scripting.FileSystemObject")ruta = ThisWorkbook.Path & "\Facturados\"Set carpeta = fso.GetFolder(ruta)Set factdos = carpeta.Files

    Sheets("Hoja1").ActivateRange("AA3").SelectIf Range("AA4") "" Then Range(Selection, Selection.End(xlDown)).SelectEnd IfSelection.ClearContents

    Range("AA3").SelectFor Each archivo In factdosActiveCell = archivo.NameActiveCell.Offset(1, 0).SelectNext

    Set fso = NothingSet carpeta = NothingSet pedidos = Nothing

    End SubSub factura_volcados()Application.ScreenUpdating = False Call Lista_volcados Call BORRAFACTVOLC

    Formfacturados.Show LIBRO = Formfacturados.ComboBox1 Set factura = Formfacturados.ComboBox2 ActiveSheet.Range("K1").Select

    Range("K:K").Find(What:=factura, LookAt:=xlWhole, SearchOrder:=xlByColumns).Selectcliente = ActiveCell.Offset(0, -7).Textfecha_factr = ActiveCell.Offset(0, 1)

    Range(ActiveCell.Offset(0, -6), ActiveCell.Offset(0, -2)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy ThisWorkbook.Activate Sheets("Factura").Select Range("G5") = fecha_factr Range("H6") = factura Range("H11") = cliente

    Range("D18").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

  • Macros_volcado - 3 Workbooks(LIBRO).Activate Sheets("Hoja1").Activate Range("A1").Select Range("K:K").Find(What:=factura, LookAt:=xlWhole).Select Range(ActiveCell.Offset(0, -10), ActiveCell.Offset(0, -9)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy

    ThisWorkbook.Activate Sheets("Factura").Activate Range("B18").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("B18").Select Application.CutCopyMode = False Workbooks(LIBRO).Close Unload Formfacturados End Sub

    Sub BORRAFACTVOLC()With Sheets("Factura") .Range("G5:H5").ClearContents .Range("H6").ClearContents .Range("H11").ClearContents .Range("B18:H53").ClearContentsEnd WithEnd SubSub Rectnguloredondeado_Haga_clic_en()UserForm10.ShowEnd Sub

  • Rellenar_facturables - 1 Private Sub BotonANADIRLEMENTO_Click()Application.ScreenUpdating = FalseIf ComboMARCA = "" Or ComboMODELO = "" Or TextBoxCantAnadir = "" Then MsgBox "RELLENE TODOS LOS CAMPOS POR FAVOR", vbExclamation ComboMARCA.Clear ComboMODELO.Clear Unload Rellenar_facturables Exit Sub End If On Error Resume Next ActiveCell.Offset(0, 2).Value = ActiveCell.Offset(0, 2).Value + TextBoxCantAnadir

    ComboMARCA.Clear ComboMODELO.Clear TextBoxMODELO = "" TextBoxCantAnadir = "" With TextBoxSTOCK .Value = "" .BackColor = vbWhite .ForeColor = vbBlack .Font.Bold = False End With Application.ScreenUpdating = True End Sub

    Private Sub CommandButtonCANCELAR_Click() 'Cancela y borra formularioOn Error Resume Next ComboMARCA.Clear ComboMODELO.Clear TextBoxMODELO = "" TextBoxCANTIDAD = "" TextBoxPRECIO = "" TextBoxSTOCK = "" TextBoxCantAnadir = "" Unload Rellenar_facturables Range("A1").SelectEnd Sub

    Private Sub BotonCancelar_Click()

    ComboMARCA.Clear ComboMODELO.Clear TextBoxMODELO = "" TextBoxCANTIDAD = "" TextBoxPRECIO = "" Unload Rellenar_facturablesEnd Sub

    Private Sub ComboMARCA_Enter() 'Carga marcas en combo

  • Rellenar_facturables - 2 On Error Resume Next ComboMODELO.Clear For l = 11 To Sheets.Count ComboMARCA.AddItem Sheets(l).Name Next End Sub

    Private Sub ComboMODELO_Change() 'Carga datos en los textbox On Error Resume Next

    Cells(ComboMODELO.ListIndex + 2, 2).Select TextBoxMODELO = ActiveCell.Offset(0, -1) TextBoxPRECIO = ActiveCell.Offset(0, 1) & " " TextBoxSTOCK = ActiveCell.Offset(0, 2) End Sub

    Private Sub ComboMODELO_Enter() 'Carga los descripciones en el combo On Error Resume Next Application.ScreenUpdating = False

    ComboMODELO.Clear lista_corresp = ComboMARCA.List(ComboMARCA.ListIndex) Sheets(lista_corresp).Select

    Range("B2").Select Do While Not IsEmpty(ActiveCell) ComboMODELO.AddItem ActiveCell ActiveCell.Offset(1, 0).Select Loop End Sub

    Private Sub CommandACEPTARP_Click() ''Vuelca datos a la hoja Presupuesto (2)

    Sheets("Presupuesto (2)").Select If ComboMARCA = "" Or ComboMODELO = "" Or TextBoxCANTIDAD = "" Then MsgBox ("RELLENE TODOS LOS CAMPOS POR FAVOR") ComboMARCA.Clear ComboMODELO.Clear Unload Rellenar_facturables End If

    On Error Resume Next ActiveCell = ComboMARCA ActiveCell.Offset(0, 1) = TextBoxMODELO ActiveCell.Offset(0, 2) = ComboMODELO ActiveCell.Offset(0, 3) = TextBoxCANTIDAD ActiveCell.Offset(0, 4) = CDbl(TextBoxPRECIO)

  • Rellenar_facturables - 3 ComboMARCA.Clear ComboMODELO.Clear TextBoxMODELO = "" TextBoxCANTIDAD = "" TextBoxPRECIO = "" Unload Rellenar_facturables Rellenar_facturables.Hide Range("A1").Select End Sub

    Private Sub CommandACEPTARA_Click() 'Vuelca datos a la hoja albarn If ComboMARCA = "" Or ComboMODELO = "" Or TextBoxCANTIDAD = "" Then MsgBox "RELLENE TODOS LOS CAMPOS POR FAVOR", vbExclamation ComboMARCA.Clear ComboMODELO.Clear Unload Rellenar_facturables Exit Sub End If ActiveCell.Offset(0, 2).Value = ActiveCell.Offset(0, 2) - TextBoxCANTIDAD Sheets("Albaran").Select On Error Resume Next ActiveCell = ComboMARCA ActiveCell.Offset(0, 1) = TextBoxMODELO ActiveCell.Offset(0, 2) = ComboMODELO ActiveCell.Offset(0, 3) = TextBoxCANTIDAD ActiveCell.Offset(0, 4) = CDbl(TextBoxPRECIO) ComboMARCA.Clear ComboMODELO.Clear TextBoxCANTIDAD = "" TextBoxMODELO = "" TextBoxPRECIO = "" Unload Rellenar_facturables End Sub

    Private Sub CommandButtonC_Click()

    ComboMARCA.Clear ComboMODELO.Clear TextBoxMODELO = "" TextBoxSTOCK = "" TextBoxCantAnadir = "" Unload Rellenar_facturables Sheets("INICIO").ActivateEnd Sub

  • Rellenar_facturables - 4 Private Sub TextBoxSTOCK_Change()With TextBoxSTOCK If .Value < 3 Then .BackColor = vbRed .ForeColor = vbWhite .Font.Bold = True MsgBox "LAS EXISTENCIAS ESTN BAJ0 MINIMOS", vbCritical Exit Sub End If If .Value < 5 Then .BackColor = &HFFFF& .ForeColor = vbRed .Font.Bold = True MsgBox "QUEDAN MENOS DE CINCO ITEMS EN EL ALMACEN", vbExclamation End IfEnd WithEnd Sub

    Private Sub UserForm_Deactivate() 'Rehabilita los botones CommandButtonACEPTARA.Enabled = True CommandButtonACEPTARA.Visible = True CommandACEPTARP.Enabled = True CommandACEPTARP.Visible = True End Sub

    ThisWorkbook - 1 Private Sub Workbook_Open()Sheets("INICIO").ScrollArea = "A1:T50"Sheets("INICIO").ActivateEnd Sub

    UserForm1 - 2 CommandButton3.ForeColor = vbBlackCommandButton4.ForeColor = vbBlackCommandButton5.ForeColor = vbBlackEnd Sub

  • UserForm1 - 1 Private Sub CommandButton1_Click() lanza_facturables_alta_items Unload UserForm1End Sub

    Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)CommandButton1.ForeColor = &HFFFF&End Sub

    Private Sub CommandButton2_Click()'CuadroMsgItems.Showlanza_actualiza_existenciasUnload UserForm1End Sub

    Private Sub CommandButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)CommandButton2.ForeColor = &HFFFF&End Sub

    Private Sub CommandButton3_Click()lanza_generar_pedidoUnload UserForm1End Sub

    Private Sub CommandButton3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)CommandButton3.ForeColor = &HFFFF&End Sub

    Private Sub CommandButton4_Click()registro_de_pedidosUnload UserForm1End Sub

    Private Sub CommandButton4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)CommandButton4.ForeColor = &HFFFF&End Sub

    Private Sub CommandButton5_Click()Unload UserForm1

    End Sub

    Private Sub CommandButton5_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)CommandButton5.ForeColor = &HFFFF&End Sub

    Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)CommandButton1.ForeColor = vbBlackCommandButton2.ForeColor = vbBlack

  • UserForm10 - 1 Private Sub CommandButton1_Click()Unload UserForm10IR_A_FACTEMITEnd Sub

    Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With CommandButton1 .ForeColor = vbYellow .BackColor = vbBlackEnd WithEnd Sub

    Private Sub CommandButton2_Click()Unload UserForm10factura_volcadosEnd Sub

    Private Sub CommandButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With CommandButton2 .ForeColor = vbYellow .BackColor = vbBlackEnd WithEnd Sub

    Private Sub CommandButton3_Click()Unload UserForm10With Hoja7.Label3 .ForeColor = vbBlack .BackColor = vbYellowEnd WithIR_A_FACTEMIT

    End Sub

    Private Sub CommandButton3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With CommandButton3 .ForeColor = vbYellow .BackColor = vbBlackEnd WithEnd Sub

    Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)With CommandButton1 .ForeColor = vbBlack .BackColor = &H8000000FEnd WithWith CommandButton2 .ForeColor = vbBlack .BackColor = &H8000000FEnd WithWith CommandButton3 .ForeColor = vbBlack

  • UserForm10 - 2 .BackColor = &H8000000FEnd WithEnd Sub

    UserForm2 - 1

    Private Sub CommandButton1_Click() FACTURAYAEnd Sub

    Private Sub Label2_Click()facturatodosEnd Sub

    UserForm3 - 1

    Private Sub CommandButton1_Click()ActiveSheet.Range("A2").SelectUserForm3.Hide

    End Sub

    Private Sub CommandButton2_Click()ActiveSheet.Range("A2").SelectUserForm3.HideEndEnd Sub

    UserForm4 - 1 Private Sub CommandButton1_Click()Unload UserForm4End Sub

  • UserForm5 - 1 Private Sub ComboBox1_Change()Label1.Caption = "Nombre del archivo"Call proveedor_pedidoEnd Sub

    Private Sub ComboBox1_Enter() Application.ScreenUpdating = False On Error Resume Next Sheets("PROVEEDORES").Activate Range("A2").Select Do While Not IsEmpty(ActiveCell) ComboBox1.AddItem ActiveCell ActiveCell.Offset(1, 0).Select Loop End Sub

    Private Sub ComboBox2_Enter()Application.ScreenUpdating = False

    Sheets("Hoja1").ActivateRange("V3").Select

    Do While Not IsEmpty(ActiveCell) ComboBox2.AddItem ActiveCell ActiveCell.Offset(1, 0).Select Loop

    End Sub

    Private Sub CommandButton1_Click()generar_pedidoUnload UserForm5End Sub

    Private Sub CommandButton2_Click()actualiza_existenciasUnload UserForm5End Sub

  • UserForm8 - 1

    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 IfEnd IfEnd Sub

    Private Sub BotonCancelar_Click() ComboBoxNIF2 = "" TextBoxNOMBRE = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Activate Loop ComboBoxNIF.SetFocusEnd Sub

    Private Sub BotonBAJA_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)BotonBAJA.BackStyle = fmBackStyleOpaqueBotonBAJA.ForeColor = vbWhiteEnd Sub

    Private Sub ButtonCANCELAR_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)ButtonCANCELAR.BackStyle = fmBackStyleOpaqueButtonCANCELAR.ForeColor = vbWhiteEnd 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)

  • UserForm8 - 2 ActiveCell.Offset(0, 3) = CDbl(TextBoxTELEF) ActiveCell.Offset(0, 5) = TextBoxEMAIL TextBoxNIF = "" 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, ByVal Y As Single) ButtonModif.ForeColor = vbBlack ButtonModif.BackStyle = fmBackStyleOpaqueEnd 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

  • UserForm8 - 3 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 = TrueEnd Sub

    Private Sub LabelAlta_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal 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 = TrueEnd Sub

    Private Sub LabelMod_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal 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.Visible = False ButtonModif.Visible = False Validar.Visible = False ButtonCANCELAR.Visible = False

  • UserForm8 - 4 End Sub

    Private Sub ButtonCANCELAR_Click() ComboBoxNIF2 = "" TextBoxNIF = "" TextBoxNOMBRE = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Activate LoopEnd Sub

    Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)LabelAlta.ForeColor = vbWhiteLabelMod.ForeColor = &H80FF80BotonBAJA.BackStyle = fmBackStyleTransparentBotonBAJA.ForeColor = &HFF&ButtonCANCELAR.BackStyle = fmBackStyleTransparentButtonCANCELAR.ForeColor = &H80FF80ButtonModif.ForeColor = &HFFFF&ButtonModif.BackStyle = fmBackStyleTransparentValidar.BackStyle = fmBackStyleTransparentValidar.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 = ""

  • UserForm8 - 5 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

    UserForm9 - 1 Private Sub ComboBox1_Enter() Application.ScreenUpdating = False

    ComboBox1.Clear Sheets("Lista de Clientes").Select Range("B2").Select

    Do While Not IsEmpty(ActiveCell) ComboBox1.AddItem ActiveCell.Value ActiveCell.Offset(1, 0).Select Loop End Sub

    Private Sub CommandButton1_Click() Application.ScreenUpdating = False On Error Resume Next Cells(ComboBox1.ListIndex + 2, 2).Select Set varNOMBRE = ActiveCell Set varNIF = ActiveCell.Offset(0, -1) Set varDIRECCION = ActiveCell.Offset(0, 1) Set varCP = ActiveCell.Offset(0, 3) Set varTELEF = ActiveCell.Offset(0, 2) Set varEMAIL = ActiveCell.Offset(0, 4) Set varNUMCLI = ActiveCell.Offset(0, 5) Sheets("Albaran").Select Range("G7") = varNOMBRE Range("G6") = varNIF Range("G9") = varDIRECCION Range("G10") = CDbl(varCP) Range("G11") = CDbl(varTELEF) Range("G8") = varEMAIL Range("G5") = varNUMCLI Unload UserForm9 UserForm9.Hide Range("B14").Select End Sub