Professional Documents
Culture Documents
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_INICIO End 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 CommandButton1_Click() IR_A_INICIO End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) End Sub
Hoja6 - 1 Private Sub CommandButton1_Click() IR_A_INICIO End Sub Private Sub CommandButton2_Click() BorrarAlbarancondowhile End Sub Private Sub Label1_Click() If Range("F4") = "A" Then Generalbaran Else Generafactinmediata End If End Sub Private Sub Label2_Click() UserForm8.Show Sheets("Albaran").Activate End Sub
Private Sub ToggleButton1_Click() Application.ScreenUpdating = False If ToggleButton1.Value = True Then Range("B2") = "Factura" Range("E3") = "N Factura" Range("E54") = "Suma Factura" Rows("55:56").EntireRow.Hidden = False Label1.Caption = "GENERAR FACTURA" Else Range("B2") = "Albarn" Range("E3") = "N Albarn" Range("E54") = "Suma Albarn" Rows("55:56").EntireRow.Hidden = True Label1.Caption = "GENERAR ALBARAN" End If End Sub Private Sub Worksheet_Activate() ScrollArea = "a1:h69" End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'If Not Application.Intersect(Target, Range("G7")) Is Nothing Then 'Range("A1").Value = Range("A1").Value + 1 'End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("B14:B36")) Is Nothing Then
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
Macros_Almacen - 1 Sub Botn_Borrar_Albaran() Application.ScreenUpdating = False Sheets("Albaran").Select items = Range("C54") Range("C14").Activate If Range("C14") = "" Then GoTo borranombre End If For b = 1 To items hoja = ActiveCell.Offset(0, -1) 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 Next b Range("B14:F52").ClearContents borranombre: Range("G5:G11").ClearContents Range("A1").Activate End Sub Sub IR_A_INICIO() Sheets("INICIO").Activate End Sub Sub IR_A_ALBARAN() Sheets("Albaran").Activate End Sub Sub IR_A_FACT() Sheets("Facturacion").Activate End Sub Sub IR_A_FACTEMIT() Sheets("Facturas emitidas").Activate End Sub Sub Muestra_User8() UserForm8.Show
Macros_Almacen - 2 End Sub Sub mUESTRAuSER1() UserForm1.Show End Sub Sub actualiza_existencias() 'If MsgBox("Asegrese de que:" + Chr(13) + _ '"El Archivo de actualizacin tiene el mismo nombre que" + Chr(13) + _ '"la hoja de la marca." + Chr(13) + _ '"Ejemplo:Hoja de marca MRK; nombre del libro:MRK.xlsx" + Chr(13) + Chr(13) + _ '"RENOMBRELO SI ES PRECISO." + Chr(13) + _ '"Es esto correcto?", vbYesNo) = vbNo Then Exit Sub
Application.ScreenUpdating = False 'nlib = InputBox("Nombre del libro.....") nlib = UserForm5.ComboBox1 LIBRO = nlib & (".xlsx") ruta = ThisWorkbook.Path & "\Pedidos Recibidos\" Workbooks.Open Filename:=ruta & LIBRO Workbooks(LIBRO).Activate Sheets("Hoja1").Range("A2").Select Do While ActiveCell <> "" modelo = ActiveCell cantidad = ActiveCell.Offset(0, 2)
ThisWorkbook.Activate Sheets(nlib).Select Range("A2").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 Workbooks(LIBRO).Activate Sheets("Hoja1").Select ActiveCell.Offset(1, 0).Select Loop ThisWorkbook.Activate Sheets(nlib).Select End Sub Sub generar_pedido() Application.ScreenUpdating = False marca = UserForm5.ComboBox1
Macros_Almacen - 3 Sheets("Hoja1").Activate Range("L1:M15").Find(what:=marca, LookAt:=xlWhole).Activate npedido = Application.WorksheetFunction.Text(ActiveCell.Offset(2, 0) + 1, "0000") ActiveCell.Offset(2, ActiveCell.Offset(2, ActiveCell.Offset(2, ActiveCell.Offset(2, 0).Value = ActiveCell.Offset(2, 0).Value + 1 1).Formula = "=TEXT(TODAY(),""dd-mmm-aa"")" 1).Copy 1).PasteSpecial xlPasteValues
nombre_pedido = "PEDIDO " & marca & "-" & npedido & ".xlsx" plantilla = ThisWorkbook.Path & "\Mis Plantillas Excel\" ruta = ThisWorkbook.Path & "\Pedidos a Proveedor\" Workbooks.Add Template:=plantilla & "PEDIDO.xltx" ActiveWorkbook.SaveAs Filename:=ruta & nombre_pedido, _ FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False ThisWorkbook.Activate Sheets(marca).Activate Range("D1").Copy Range("M1") Range("M2") = "<=5" Columns("A:D").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _ "M1:M2"), CopyToRange:=Range("O1"), Unique:=False If Range("O2") = "" Then MsgBox "TODAS LAS EXISTENCIAS ESTAN " + Chr(13) + _ "POR ENCIMA DE LAS 5 UNIDADES" Workbooks(nombre_pedido).Close Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFile ruta & nombre_pedido, True Set fso = Nothing Sheets("Hoja1").Activate Range("L1:M15").Find(what:=marca, LookAt:=xlWhole).Activate ActiveCell.Offset(2, 0).Value = ActiveCell.Offset(2, 0).Value - 1 Sheets("INICIO").Activate Exit Sub End If Columns("Q:Q").Delete Range("Q2").Select Do While ActiveCell <> "" ActiveCell.Value = 10 - ActiveCell.Value ActiveCell.Offset(1, 0).Select Loop Range("O2").Select Range(Selection, Selection.End(xlToRight)).Select If Range("O3") <> "" Then Range(Selection, Selection.End(xlDown)).Select End If Selection.Copy
Macros_Almacen - 4 Workbooks(nombre_pedido).Activate Range("A2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ThisWorkbook.Activate Columns("M:Q").Delete Range("A1").Activate Workbooks(nombre_pedido).Activate Range("D1").Activate Application.CutCopyMode = False End Sub Sub lanza_facturables_alta_items() Unload UserForm1 Rellenar_facturables.CommandACEPTARP.Enabled = False Rellenar_facturables.CommandACEPTARP.Visible = False Rellenar_facturables.CommandACEPTARA.Enabled = False Rellenar_facturables.CommandACEPTARA.Visible = False Rellenar_facturables.LabePrecio.Enabled = False Rellenar_facturables.LabePrecio.Visible = False Rellenar_facturables.TextBoxCANTIDAD.Enabled = False Rellenar_facturables.TextBoxCANTIDAD.Visible = False Rellenar_facturables.TextBoxPRECIO.Enabled = False Rellenar_facturables.TextBoxPRECIO.Visible = False Rellenar_facturables.BotonCancelar.Enabled = False Rellenar_facturables.BotonCancelar.Visible = False Rellenar_facturables.Label1.Caption = "AADIR ELEMENTOS" Rellenar_facturables.Show End Sub Sub lanza_actualiza_existencias() UserForm5.CommandButton1.Enabled = False UserForm5.CommandButton1.Visible = False UserForm5.Label1.Caption = "Nombre del archivo (igual que la marca)" UserForm5.Show End Sub Sub lanza_generar_pedido() UserForm5.CommandButton2.Enabled = False UserForm5.CommandButton2.Visible = False UserForm5.Label1.Caption = "Elegir marca" UserForm5.Show End Sub Sub registro_de_pedidos() On Error Resume Next Application.ScreenUpdating = False Set fso = CreateObject("Scripting.FileSystemObject") ruta = ThisWorkbook.Path & "\Pedidos a Proveedor\" Set carpeta = fso.GetFolder(ruta) Set pedidos = carpeta.Files
Macros_Almacen - 5
Sheets("Hoja1").Activate Range("P3").Select For Each archivo In pedidos ActiveCell = archivo.Name ActiveCell.Offset(0, 1) = FormatDateTime(archivo.DateCreated, vbShortDate) ActiveCell.Offset(1, 0).Select Next Set fso = Nothing Set carpeta = Nothing Set pedidos = Nothing Application.ScreenUpdating = True End Sub Sub BorrarAlbarancondowhile() Application.ScreenUpdating = False Sheets("Albaran").Select Range("C14").Activate If Range("C14") = "" Then GoTo borranombre End If Do While ActiveCell <> "" hoja = ActiveCell.Offset(0, -1) 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").Activate End Sub
Macros_antiguas - 1 Sub facturatodos() UserForm2.Hide Range("A2").Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.Cut Sheets("Facturas Emitidas").Activate Range("A2").Select Selection.Insert Shift:=xlDown Sheets("Facturacion").Activate Range("A2").Select End Sub Sub DatosCuadro4() 'PASA DATOS DE FACTURA Y CLIENTE A HOJA 1 PARA EL CUADRO 4 Application.ScreenUpdating = False Sheets("Facturas Emitidas").Range("J2").Activate Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select 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 Range(Selection, Selection.End(xlDown)).Select Application.CutCopyMode = False Selection.Copy Sheets("Hoja1").Activate Range("C2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("A2").Activate 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 Botn2_Haga_clic_en() UserForm6.Show End Sub Sub numerocliente() Sheets("Facturas emitidas").Activate Range("K2").Copy Selection.CurrentRegion.Select Selection.SpecialCells(xlCellTypeBlanks).Select
Sub FACTURALCLIENTE() UserForm3.Show UserForm2.Show End Sub Sub Copianumfactura() 'RELLENA CON FORMULAS DE NUMERO DE FACTURA Sheets("Facturas emitidas").Activate Range("K2").Copy Selection.CurrentRegion.Select Selection.SpecialCells(xlCellTypeBlanks).Select ActiveSheet.Paste Application.CutCopyMode = False Range("A2").Select End 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 End Sub
Macros_nuevas - 2 Sheets("Presupuesto (2)").Activate End Sub Sub RELLENENOMBREALBARAN() Application.ScreenUpdating = False Set fila = Cells(1, 1) Sheets("Lista de Clientes").Select Cells(fila + 1, 2).Select Set Set Set Set Set Set Set varNOMBRE = ActiveCell varNIF = ActiveCell.Offset(0, -1) varDIRECCION = ActiveCell.Offset(0, 1) varCP = ActiveCell.Offset(0, 3) varTELEF = ActiveCell.Offset(0, 2) varEMAIL = ActiveCell.Offset(0, 4) 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") Set varNUMALB = Range("G3") Set varNOMBRE = Range("G7") Set varNIF = Range("G6") Set varID = Range("F4")
Macros_nuevas - 3 Set items = Range("C54") ' copiamos los artculos del albarn Range("C14").Select If Range("C15") <> Range(Selection, Range(Selection, Else Range(Selection, End If Selection.Copy "" Then Selection.End(xlDown)).Select Selection.End(xlToRight)).Select Selection.End(xlToRight)).Select
' 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) = ActiveCell.Offset(0, 2) = ActiveCell.Offset(0, 3) = ActiveCell.Offset(0, 9) = 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() 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
Macros_nuevas - 4 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) Next I ' volvemos a la hoja albarn y borramos todo Sheets("Albaran").Select Range("G5:G11").ClearContents
Macros_nuevas - 5 Range("B14:F52").ClearContents Range("A1").Select End Sub Sub IMPRIMIR() 'IMPRIME DOCUMENTO EN IMPRESORA PREDEFINIDA ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _ IgnorePrintAreas:=False End Sub Sub lanza_facturables_albaran() Rellenar_facturables.CommandACEPTARP.Enabled = False Rellenar_facturables.CommandACEPTARP.Visible = False Rellenar_facturables.BotonANADIRLEMENTO.Enabled = False Rellenar_facturables.BotonANADIRLEMENTO.Visible = False Rellenar_facturables.TextBoxCantAnadir.Enabled = False Rellenar_facturables.TextBoxCantAnadir.Visible = False Rellenar_facturables.LabelANADIR.Enabled = False Rellenar_facturables.LabelANADIR.Visible = False Rellenar_facturables.CommandButtonC.Enabled = False Rellenar_facturables.CommandButtonC.Visible = False Rellenar_facturables.Label1.Caption = "ELEGIR UN EQUIPO" Rellenar_facturables.Show End Sub Sub lanza_facturables_presupuesto() Rellenar_facturables.CommandACEPTARA.Enabled = False Rellenar_facturables.CommandACEPTARA.Visible = False Rellenar_facturables.BotonANADIRLEMENTO.Enabled = False Rellenar_facturables.BotonANADIRLEMENTO.Visible = False Rellenar_facturables.TextBoxCantAnadir.Enabled = False Rellenar_facturables.TextBoxCantAnadir.Visible = False Rellenar_facturables.LabelANADIR.Enabled = False Rellenar_facturables.LabelANADIR.Visible = False Rellenar_facturables.CommandButtonC.Enabled = False Rellenar_facturables.CommandButtonC.Visible = False Rellenar_facturables.Label1.Caption = "ELEGIR UN EQUIPO" Rellenar_facturables.Show End Sub Sub Imprimefacturas() Application.ScreenUpdating = False On Error Resume Next Sheets("Hoja1").Range("A2:C1000").ClearContents Sheets("Hoja3").Range("B10:H1000").ClearContents DatosCuadro4 FiltraCuadro4 UserForm4.Show Range("A2").Select Columns("A:K").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _ "M1:N2"), CopyToRange:=Range("Q1:AA1"), Unique:=False Application.CutCopyMode = False Range("Q2:R2").Select If Range("Q3") <> "" Then
Macros_nuevas - 6 Range(Selection, Selection.End(xlDown)).Select End If Selection.Copy Sheets("Hoja3").Select Range("B10").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Sheets("Facturas Emitidas").Select Range("U2:Y2").Select If Range("Q3") <> "" Then Range(Selection, Selection.End(xlDown)).Select End If Selection.Copy Sheets("Hoja3").Select Range("D10").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("H10").Select Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Select Loop ActiveCell.Offset(1, 0).Select ActiveCell.FormulaR1C1 = "=sum(R10C:R[-2]C)" ActiveCell.Offset(1, 0).FormulaR1C1 = "=(R[-1]C)*18%" ActiveCell.Offset(2, 0).FormulaR1C1 = "=sum(R[-1]C:R[-2]C)" ActiveCell.Offset(0, -1).Value = "Suma" ActiveCell.Offset(1, -1).Value = "IVA 18%" ActiveCell.Offset(2, -1).Value = "Total" AreaImpresion End Sub
Sub AreaImpresion() Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Activate With ActiveCell.Offset(2, 0) celda = .Address End With ActiveSheet.PageSetup.PrintArea = "$B$1:" & celda End Sub
Rellenar_facturables - 1 Private Sub BotonANADIRLEMENTO_Click() Application.ScreenUpdating = False If 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() On Error Resume Next ComboMARCA.Clear ComboMODELO.Clear TextBoxMODELO = "" TextBoxCANTIDAD = "" TextBoxPRECIO = "" TextBoxSTOCK = "" TextBoxCantAnadir = "" Unload Rellenar_facturables Range("A1").Select End Sub Private Sub BotonCancelar_Click() ComboMARCA.Clear ComboMODELO.Clear TextBoxMODELO = "" TextBoxCANTIDAD = "" TextBoxPRECIO = "" Unload Rellenar_facturables End Sub Private Sub ComboMARCA_Enter() 'Carga marcas en combo 'Cancela y borra formulario
Rellenar_facturables - 2 On Error Resume Next ComboMODELO.Clear For l = 10 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").Activate End 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 If End With End Sub Private Sub UserForm_Deactivate() 'Rehabilita los botones CommandButtonACEPTARA.Enabled = True CommandButtonACEPTARA.Visible = True CommandACEPTARP.Enabled = True CommandACEPTARP.Visible = True End Sub
UserForm1 - 1 Private Sub CommandButton1_Click() lanza_facturables_alta_items Unload UserForm1 End 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.Show lanza_actualiza_existencias Unload UserForm1 End 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_pedido Unload UserForm1 End 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_pedidos Unload UserForm1 End 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 = vbBlack CommandButton2.ForeColor = vbBlack
UserForm3 - 1
Private Sub CommandButton1_Click() ActiveSheet.Range("A2").Select UserForm3.Hide End Sub Private Sub CommandButton2_Click() ActiveSheet.Range("A2").Select UserForm3.Hide End End Sub
UserForm4 - 1
Private Sub ComboBox1_Change() End Sub Private Sub CommandButton1_Click() UserForm4.Hide End Sub Private Sub Label1_Click() End Sub Private Sub UserForm_Click() End Sub
UserForm5 - 1 Private Sub ComboBox1_Enter() On Error Resume Next For l = 10 To Sheets.Count ComboBox1.AddItem Sheets(l).Name Next End Sub Private Sub CommandButton1_Click() generar_pedido Unload UserForm5 End Sub Private Sub CommandButton2_Click() actualiza_existencias Unload UserForm5 End Sub
UserForm7 - 1
Range("G6") = TextBoxNIF Range("G7") = ComboBoxNOMBRE Range("G8") = TextBoxDIRECCION Range("G9") = CDbl(TextBoxCP) Range("G10") = CDbl(TextBoxTELEF) Range("D7") = TextBoxEMAIL Range("D8") = TextBoxNUMCLI ComboBoxNOMBREF = "" TextBoxNIF = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" TextBoxNUMCLI = "" UserForm7.Hide End Sub Private Sub CANCELAR_Click() ComboBoxNOMBRE = "" TextBoxNIF = "" TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" TextBoxNUMCLI = "" Do While Not IsEmpty(ActiveCell) ActiveCell.Offset(1, 0).Activate Loop ComboBoxNOMBRE.SetFocus End Sub Private Sub ComboBoxNOMBRE_Change() Application.ScreenUpdating = False Cells(ComboBoxNOMBRE.ListIndex + 2, 2).Select TextBoxNIF = ActiveCell.Offset(0, -1) TextBoxDIRECCION = ActiveCell.Offset(0, 1) TextBoxCP = ActiveCell.Offset(0, 3) TextBoxTELEF = ActiveCell.Offset(0, 2) TextBoxEMAIL = ActiveCell.Offset(0, 4) TextBoxNUMCLI = ActiveCell.Offset(0, 5)
UserForm7 - 2 End Sub Private Sub ComboBoxNOMBRE_Enter() Application.ScreenUpdating = False ComboBoxNOMBRE.Clear Sheets("Lista de Clientes").Select Range("B2").Select Do While Not IsEmpty(ActiveCell) ComboBoxNOMBRE.AddItem ActiveCell.Value ActiveCell.Offset(1, 0).Select Loop End Sub
Private Sub UserForm_Activate() TextBoxNIF = "" ComboBoxNOMBRE.Clear TextBoxDIRECCION = "" TextBoxCP = "" TextBoxTELEF = "" TextBoxEMAIL = "" ComboBoxNUMCLI = "" ComboBoxNOMBRE.SetFocus End Sub
UserForm8 - 1
Private Sub BotonBAJA_Click() If MsgBox("SEGURO QUE QUIERE ELIMINAR ESTE CLIENTE?", vbExclamation + vbYesNo) = vbYes Th en 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, ByVal 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 Single, 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)
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 Singl e, ByVal 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
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 = True End 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 = True End 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.Enabled = False BotonBAJA.Visible = False ButtonModif.Enabled = False ButtonModif.Visible = False
UserForm8 - 4 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, ByVal 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
UserForm8 - 5 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, By Val 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 Set Set Set Set Set Set varNOMBRE = ActiveCell varNIF = ActiveCell.Offset(0, -1) varDIRECCION = ActiveCell.Offset(0, 1) varCP = ActiveCell.Offset(0, 3) varTELEF = ActiveCell.Offset(0, 2) varEMAIL = ActiveCell.Offset(0, 4) 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
End Sub