03_ANEXO B

Anuncio
ANEXO B
Macros del archivo .xlsm
Hoja4 - 1
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address(False, False) = "B7" Then
If Target.Value <> "" Then Call M21_Día_Hora
End If
End Sub
Md00_Datos - 1
Sub M00_Plantilla_Datos()
'Botón CTRL+a
'ATENCIÓN: Guardar archivo con otro nombre antes de pulsar porque se borran los datos
'Borrar Botones
ActiveSheet.Shapes.SelectAll
Selection.Cut
'Borrar Texto
Range("D2:BB65536").Select
Selection.ClearContents
'Borrar Bordes
Range("D6:BB65536").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'Color de Fondo
Range("D2:BB65536").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
'Letra: Tipo y Color
Range("D2:BB65536").Select
With Selection.Font
.Name = "Arial Narrow"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0
End With
'Ancho de Columna
Columns("A:A").ColumnWidth = 2.14
Columns("B:B").ColumnWidth = 5
Columns("C:C").ColumnWidth = 2.14
Columns("D:D").ColumnWidth = 13.57
Columns("E:BZ").ColumnWidth = 4.89
'Ancho de Fila
Rows("1:65536").Select
Selection.RowHeight = 15
'Fijar Filas y Columnas Superiores
Range("D6").Select
ActiveWindow.FreezePanes = True
'Rótulos
Range("D2:AM2") = Array("ENTRADA", "T_00", "T_01", "T_02", "T_03", "T_04", "T_05", "T_06", "T_07",
"T_12", "T_13", "T_14", "T_15", "T_16", "T_17", "T_18", "T_19", "T_21", "T_22", "V_1", "V_2", "V_3"
, "V_4", "M_1", "M_2", "M_3", "M_4", "INV", "I_MP", "I_FC", "AT", "SP", "AUT", "M_01", "M_06", "P_1
")
Range("D5:AM5") = Array("FECHA - HORA", "T_00", "T_01", "T_02", "T_03", "T_04", "T_05", "T_06", "T_
07", "T_12", "T_13", "T_14", "T_15", "T_16", "T_17", "T_18", "T_19", "T_21", "T_22", "V_1", "V_2",
"V_3", "V_4", "M_1", "M_2", "M_3", "M_4", "INV", "I_MP", "I_FC", "AT", "SP", "AUT", "M_01", "M_06",
"P_1")
Md00_Datos - 2
'Bordes y Relleno del Buffer
Range("D2:AM3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ThemeColor = 9
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("D3:AM3").Select
With Selection.Font
.Name = "Arial Narrow"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorAccent6
.TintAndShade = -0.249977111
.ThemeFont = xlThemeFontNone
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
'Fila 1ª de Datos Registrados
'Bordes
Range("D5:AM6").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ThemeColor = 9
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'Relleno
Range("D6:AM6").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
'Formato para Columna de Fecha y Hora
Columns("D:D").Select
Selection.NumberFormat = "d-m-yy h:mm;@"
'Botón 1
'Parámetros: Eje X, Eje Y, Ancho, Alto
ActiveSheet.Buttons.Add(16, 15.75, 28.5, 14).Select
Selection.OnAction = "M10_Buffer"
Selection.Characters.Text = "IMP"
With Selection.Characters(Start:=1, Length:=8).Font
.Name = "Arial Narrow"
Md00_Datos - 3
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 49
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = False
End With
'Botón 2
'Parámetros: Eje X, Eje Y, Ancho, Alto
ActiveSheet.Buttons.Add(16, 30.75, 28.5, 14).Select
Selection.OnAction = "M11_Registro"
Selection.Characters.Text = "ON"
With Selection.Characters(Start:=1, Length:=8).Font
.Name = "Arial Narrow"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 49
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = False
End With
'Botón 3
'Parámetros: Eje X, Eje Y, Ancho, Alto
ActiveSheet.Buttons.Add(16, 45.75, 28.5, 14).Select
Selection.OnAction = "M12_Stop"
Selection.Characters.Text = "OFF"
With Selection.Characters(Start:=1, Length:=8).Font
.Name = "Arial Narrow"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 49
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = False
End With
'Ocultar Columnas
Columns("AM:BF").Select
Selection.EntireColumn.Hidden = True
Range("D3").Select
Range("A1").Select
End Sub
Md01_Gráfica - 1
Sub M01_Plantilla_Gráfica()
'Botón CTRL+b
'Borrar Botones
ActiveSheet.Shapes.SelectAll
Selection.Cut
'Borrar Texto y Formato Condicional
ActiveSheet.Select
Selection.ClearContents
Cells.FormatConditions.Delete
'Borrar Bordes
Range("D3:AL3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'Color de Fondo
ActiveSheet.Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
'Letra: Tipo y Color
ActiveSheet.Select
With Selection.Font
.Name = "Arial Narrow"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0
End With
'Ancho de Columna
Columns("A:A").ColumnWidth = 2.14
Columns("B:B").ColumnWidth = 6.43
Columns("C:C").ColumnWidth = 2.14
Columns("D:BZ").ColumnWidth = 4.89
'Ancho de Fila
Rows("1:65536").Select
Selection.RowHeight = 15
'Fijar Filas y Columnas Superiores
Range("D6").Select
ActiveWindow.FreezePanes = True
'Botón
'Parámetros: Eje X, Eje Y, Ancho, Alto
ActiveSheet.Buttons.Add(16, 30.75, 35, 14).Select
Selection.OnAction = "M31_Gráfica"
Selection.Characters.Text = "GRAF"
With Selection.Characters(Start:=1, Length:=8).Font
.Name = "Arial Narrow"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 49
Md01_Gráfica - 2
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = False
End With
'Rótulos
Range("E2:AM2") = Array("T_00", "T_01", "T_02", "T_03", "T_04", "T_05", "T_06", "T_07", "T_12", "T_
13", "T_14", "T_15", "T_16", "T_17", "T_18", "T_19", "T_21", "T_22", "V_1", "V_2", "V_3", "V_4", "M
_1", "M_2", "M_3", "M_4", "INV", "I_MP", "I_FC", "AT", "SP", "AUT", "M_01", "M_06", "P_01")
'Bordes y Relleno
Range("E2:AM3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ThemeColor = 9
.TintAndShade = -0.249946592608417
.Weight = xlThin
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("E3:AM3").Select
With Selection.Font
.Name = "Arial Narrow"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorAccent6
.TintAndShade = -0.249977111
.ThemeFont = xlThemeFontNone
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Range("AN2:AN3").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
'Casillas de Verificación
'Parámetros: Eje X, Eje Y, Ancho, Alto
cas_n = 1
cas_y = 5
cas_dy = 30.35
cas_ref = Cells(4, cas_y).Address
Md01_Gráfica - 3
While cas_n <> 36
ActiveSheet.CheckBoxes.Add(110 + (cas_n - 1) * cas_dy, 29, 24, 17.25).Select
With Selection
.Value = xlOff
.LinkedCell = cas_ref
.Display3DShading = False
.Characters.Text = ""
End With
cas_n = cas_n + 1
cas_y = cas_y + 1
cas_ref = Cells(4, cas_y).Address
Wend
'Ocultar Fila vinculada a Casillas de Verificación
Rows("4:4").Select
Selection.EntireRow.Hidden = True
'Fijar Filas y Columnas Superiores
Range("D6").Select
ActiveWindow.FreezePanes = True
'Ocultar Columnas
Columns("D:D").Select
Selection.EntireColumn.Hidden = True
Columns("AM:AZ").Select
Selection.EntireColumn.Hidden = True
'Formato Listas Desplegables
Range("E1").Select
Range("A1").Select
End Sub
Md10_Buffer - 1
Sub M10_Buffer()
'Botón CTRL+c
'Temperaturas
Range("E3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
0 "
Range("F3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
1 "
Range("G3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
2 "
Range("H3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
3 "
Range("I3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
4 "
Range("J3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
5 "
Range("K3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
6 "
Range("L3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_0
7 "
Range("M3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
2 "
Range("N3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
3 "
Range("O3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
4 "
Range("P3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
5 "
Range("Q3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
6 "
Range("R3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
7 "
Range("S3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
8 "
Range("T3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_1
9 "
Range("U3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_2
1 "
Range("V3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\T_2
2 "
Md10_Buffer - 2
Range("W3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\V_1
"
Range("X3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\V_2
"
Range("Y3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\V_3
"
Range("Z3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\V_4
"
Range("AA3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\M_1
"
Range("AB3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\M_2
"
Range("AC3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\M_3
"
Range("AD3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\M_4
"
Range("AE3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\INV
"
Range("AF3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\INV
_MP "
Range("AG3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\INV
_FC "
Range("AH3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\AT
"
Range("AI3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\AT_
SP "
Range("AJ3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\AUT
"
Range("AK3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\Mod
o01 "
Range("AL3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\Mod
o06 "
Range("AM3").Select
ActiveCell.FormulaR1C1 = "=CDMDDE|'C:\Archivos de Programa\OMRON\CX-Server\DDE_ALM\DDE_01.cdm'!\P_1
"
Range("D3").Select
End Sub
Md11_Registro - 1
Sub M11_Registro()
'Ir a Hoja Última
Sheets(Sheets.Count).Select
'Índice de la Hoja de Registro de Datos
i = ActiveSheet.Index
'Formato para Columna de Fecha y Hora
Columns("D:D").Select
Selection.NumberFormat = "d-m-yy h:mm;@"
'Fecha y Hora
Range("D3").Select
ActiveCell.FormulaR1C1 = "=NOW()"
'Seguir en 1ª Fila Vacía
a = 6
b = 4
While Cells(a, b) <> ""
a = a + 1
Wend
Range("D3:AM3").Select
Selection.Copy
Range(Cells(a, b), Cells(a, b)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Nombrar Hoja según Mes y Año
mes_aho = Month(Cells(3, 4))
mes_ini = Month(Cells(6, 4))
If Range("D6").Value = "" Or mes_aho = mes_ini Then
ActiveSheet.Name = UCase(MonthName(Month(Cells(3, 4)), 1)) & "'" & Right(Year(Cells(3, 4)), 2)
Else:
Range(Cells(a, b), Cells(a, b + 35)).Select
Selection.Delete
Application.CutCopyMode = False
'Desactivar Filtro si procede
If ActiveSheet.FilterMode = True Then
Range("D5").Select
Selection.AutoFilter
End If
Call M13_Nuevo
Exit Sub
End If
'Bucle Copiar y Pegar cada Minuto
t_inc = 6.8287037037037E-04 '59 seg
Do While mes_aho = mes_ini
'Pegar Datos del Buffer
Sheets(i).Select
Range("D3:AM3").Select
Selection.Copy
Range(Cells(a, b), Cells(a, b)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Dividir Datos entre 10
Range(Cells(a + 1, b + 1), Cells(a + 1, b + 1)).Select
ActiveCell.FormulaR1C1 = "=R[-1]C/10"
Range(Cells(a + 1, b + 1), Cells(a + 1, b + 1)).Select
Selection.AutoFill Destination:=Range(Cells(a + 1, b + 1), Cells(a + 1, b + 22)), Type:=xlFillD
efault
Range(Cells(a + 1, b + 1), Cells(a + 1, b + 22)).Select
Selection.Copy
Range(Cells(a + 2, b + 1), Cells(a + 2, b + 22)).Select
Md11_Registro - 2
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range(Cells(a, b + 1), Cells(a + 1, b + 22)).Select
Selection.ClearContents
Range(Cells(a + 2, b + 1), Cells(a + 2, b + 22)).Select
Selection.Copy
Range(Cells(a, b + 1), Cells(a, b + 22)).Select
ActiveSheet.Paste
Range(Cells(a + 2, b + 1), Cells(a + 2, b + 22)).Select
Selection.ClearContents
'Datos con 1 Cifra Decimal
Range(Cells(a, b + 1), Cells(a, b + 22)).Select
Selection.NumberFormat = "0.0"
'Bordes
Range(Cells(a, b), Cells(a, b + 35)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'Relleno
Range(Cells(a, b - 2), Cells(a, b - 2)).Select
ActiveCell.FormulaR1C1 = "=MOD(ROW(),2)"
res = ActiveCell.Value
Range(Cells(a, b - 2), Cells(a, b - 2)).Select
Selection.ClearContents
If res = 0 Then
Range(Cells(a, b), Cells(a, b + 35)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Else: Range(Cells(a, b), Cells(a, b + 35)).Select
End If
'Actualizar Tiempo
t_aho = Range("D3")
t_sig = t_aho + t_inc
'Mostrar Gráfica
Sheets("GRAF").Activate
'Permitir Otras Tareas mientras pasa 1 min
Do While Now < t_sig
DoEvents
Loop
'Actualizar
Sheets(i).Select
Calculate
Loop
mes_aho = Month(Cells(3, 4))
mes_ini = Month(Cells(6, 4))
a = a + 1
Md11_Registro - 3
i = i + 1
Call M13_Nuevo
End Sub
Md12_Stop - 1
Sub M12_Stop()
End
End Sub
Md13_Nuevo - 1
Sub M13_Nuevo()
'Crear Hoja Nueva en Última Posición
ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'Fecha y Hora Actual
Range("D3").Select
ActiveCell.FormulaR1C1 = "=NOW()"
'Nombrar Hoja Nueva según Mes y Año
ActiveSheet.Name = UCase(MonthName(Month(Cells(3, 4)), 1)) & "'" & Right(Year(Cells(3, 4)), 2)
'Borrar Texto
Range("D6:AL65536").Select
Selection.ClearContents
'Borrar Bordes
Range("D6:AL65536").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'Color de Fondo
Range("D6:AL65536").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Call M20_Mes
End Sub
Md20_Mes - 1
Sub M20_Mes()
'Crear Índice
Sheets("GRAF").Activate
Dim PivotCell As Range, Tmp As Range
Set PivotCell = [BA6] 'Rótulo
With PivotCell
.EntireColumn.ClearContents: .FormulaR1C1 = "MES"
.HorizontalAlignment = xlCenter
End With
For Each hoja In Application.Sheets
If ActiveSheet.Name = hoja.Name Then GoTo Loop1
Set Tmp = PivotCell.Offset(200, 0).End(xlUp).Offset(1, 0)
Tmp = hoja.Name
Loop1:
Next hoja
PivotCell.EntireColumn.AutoFit
Set Tmp = Nothing
Set PivotCell = Nothing
'Crear Lista Desplegable
lista_f = 7 'Fila donde empieza Lista SIN desplegar
While Cells(lista_f, 53) <> "" 'Baja por Columna BA
lista_f = lista_f + 1
Wend
'Ubicación de la Lista Desplegable
Range("B7").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$BA$7:$BA$" & lista_f
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
'Formato de la Lista Desplegable
Range("B6").Select
ActiveCell.FormulaR1C1 = "MES"
Range("B7").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
Md20_Mes - 2
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("E1").Select
Range("A1").Select
Call M11_Registro
End Sub
Md21_Día_Hora - 1
Sub M21_Día_Hora()
'Borrar Selección anterior
Range("B11").Select
Selection.ClearContents
Range("B13") = "0:00"
Range("B17").Select
Selection.ClearContents
Range("B19") = "23:59"
'Ocultar Cambios en la Pantalla
Application.ScreenUpdating = False
'Activar Hoja Seleccionada
c = 7
While Cells(7, 2) <> Cells(c, 53)
c = c + 1
Wend
Sheets(c - 5).Activate
'Extraer Nº Días del Mes diferentes
d = 6
While Cells(d, 4) <> ""
d = d + 1
Wend
Range("BA6").Select
ActiveCell.FormulaR1C1 = "=DAY(RC[-49])"
Range("BA6").Select
Selection.AutoFill Destination:=Range("BA6:BA" & d - 1), Type:=xlFillDefault
Range("BA6:BA" & d).Select
Selection.Copy
Range("BB6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("BB6:BB" & d - 1).Select
ActiveSheet.Range("$BB$6:$BB$" & d - 1).RemoveDuplicates Columns:=1, Header:= _
xlNo
'Arreglar el formato que se pierde
Range("BB6:BB" & d - 1).Select
With Selection.Font
.Name = "Arial Narrow"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'Copiar Días a Hoja de la Gráfica
e = 6
Md21_Día_Hora - 2
While Cells(e, 54) <> ""
e = e + 1
Wend
Range(Cells(6, 54), Cells(e, 54)).Select
Selection.Copy
Sheets("GRAF").Select
Range("BB6") = "D_INI"
Range("BB7").Select
ActiveSheet.Paste
'Lista Desplegable: Día Inicio
Sheets("GRAF").Select
f = 7
While Cells(f, 54) <> ""
f = f + 1
Wend
Range("B11").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$BB$7:$BB$" & f
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
'Lista Desplegable: Día Final
Range("B17").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$BB$7:$BB$" & f
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
'Lista Desplegable: Hora Inicio
Range("BC6") = "H_INI"
Range("BD6") = "dt"
Range("BC7:BC30").Select
Selection.NumberFormat = "h:mm;@"
Range("BC7").Value = "0:00:00 AM"
Range("BD7").Select
Selection.NumberFormat = "h:mm;@"
Range("BD7").Select
ActiveCell.FormulaR1C1 = "1:00:00 AM"
Range("BC8").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+R7C56"
Range("BC8").Select
Selection.AutoFill Destination:=Range("BC8:BC30"), Type:=xlFillDefault
Range("B13").Select
Selection.NumberFormat = "h:mm;@"
Range("B13").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$BC$7:$BC$30"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
Md21_Día_Hora - 3
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
'Lista Desplegable: Hora Final
Range("BE6") = "H_FIN"
Range("BF6") = "dt"
Range("BE7:BE30").Select
Selection.NumberFormat = "h:mm;@"
Range("BE7").Value = "0:59:00 AM"
Range("BF7").Select
Selection.NumberFormat = "h:mm;@"
Range("BF7").Select
ActiveCell.FormulaR1C1 = "1:00:00 AM"
Range("BE8").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+R7C58"
Range("BE8").Select
Selection.AutoFill Destination:=Range("BE8:BE30"), Type:=xlFillDefault
Range("B19").Select
Selection.NumberFormat = "h:mm;@"
Range("B19").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$BE$7:$BE$30"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
'Ocultar Columnas
Columns("BA:BF").Select
Selection.EntireColumn.Hidden = True
'Formato de las Listas Desplegables
Range("B9").Select
ActiveCell.FormulaR1C1 = "INICIO"
Range("B10").Select
ActiveCell.FormulaR1C1 = "DÍA"
Range("B12").Select
ActiveCell.FormulaR1C1 = "HORA"
Range("B15").Select
ActiveCell.FormulaR1C1 = "FIN"
Range("B16").Select
ActiveCell.FormulaR1C1 = "DÍA"
Range("B18").Select
ActiveCell.FormulaR1C1 = "HORA"
Range("B10").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Range("B12").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Range("B16").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
Md21_Día_Hora - 4
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Range("B18").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Range("B10:B13").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("B16:B19").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 4
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("E1").Select
Range("A1").Select
'Visualizar Cambios en la Pantalla
Application.ScreenUpdating = True
Md21_Día_Hora - 5
End Sub
Md30_Filtro - 1
Sub M30_Filtro()
Application.ScreenUpdating = False
Sheets("GRAF").Activate
'Índice de la Hoja a filtrar
hoja_f = 7
While Cells(7, 2) <> Cells(hoja_f, 53)
hoja_f = hoja_f + 1
Wend
'Ocultar Columna
Columns("BA:BA").Select
Selection.EntireColumn.Hidden = True
Sheets(hoja_f - 5).Activate
'Desactivar Filtro si procede
If ActiveSheet.FilterMode = True Then
Range("D5").Select
Selection.AutoFilter
End If
'Criterio para Filtro
año_f = Year([D6])
mes_f = Month([D6])
Sheets("GRAF").Activate
dia_if = Range("B11").Value
dia_ff = Range("B17").Value
hora_if = Hour([B13])
hora_ff = Hour([B19])
fecha_if = mes_f & "-" & dia_if & "-" & año_f & " " & hora_if & ":00"
fecha_ff = mes_f & "-" & dia_ff & "-" & año_f & " " & hora_ff & ":59"
'Filtrar
Sheets(hoja_f - 5).Activate
Range("D5").Select
Selection.AutoFilter Field:=1, Criteria1:=">=" & fecha_if, Operator:=xlAnd, Criteria2:="<=" & f
echa_ff
End Sub
Md31_Gráfica - 1
Sub M31_Gráfica()
Application.ScreenUpdating = False
Call M30_Filtro
'Índice de la Hoja filtrada
ind_f = ActiveSheet.Index
'Borrar Gráfica anteriores
Sheets("GRAF").Select
ActiveSheet.ChartObjects("1 Gráfico").Activate
Selection.Cut
ActiveSheet.ChartObjects("2 Gráfico").Activate
Selection.Cut
ActiveSheet.ChartObjects("3 Gráfico").Activate
Selection.Cut
'Copia estado de las Casillas de Verificación
'No pegar en la misma fila que el Registro, para evitar problemas con el Filtro
'Seleccionar fuente de color blanco para ocultar
Range("E4:AM4").Select
Selection.Copy
Sheets(ind_f).Select
Range("E1:AM1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Range("A1").Select
'Fila y Columna de la 1ª Celda filtrada
Range([D6], [D65536].End(xlUp)).SpecialCells(xlCellTypeVisible).Item(1).Select
x_if = ActiveCell.Row
y_if = ActiveCell.Column
'Nº Filas del filtrado
n_fil_f = Range([D6], [D65536].End(xlUp)).SpecialCells(xlCellTypeVisible).Rows.Count
'GRÁFICA 1
'Añadir Gráfica
Sheets(ind_f).Select
ActiveSheet.Shapes.AddChart.Select
'Tipo de Gráfica
'ActiveChart.ChartType = xlXYScatter
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
'Nombre
ActiveSheet.ChartObjects(1).Name = "1 Gráfico"
'Tamaño
ActiveSheet.ChartObjects("1 Gráfico").Width = 800
ActiveSheet.ChartObjects("1 Gráfico").Height = 400
'Leyenda
ActiveSheet.ChartObjects("1 Gráfico").Activate
ActiveChart.Legend.Select
Selection.Position = xlTop
'Borrar Series que aparecen por defecto
n_ser = ActiveChart.SeriesCollection.Count
While n_ser <> 0
ActiveChart.SeriesCollection(n_ser).Delete
n_ser = n_ser - 1
Wend
'Bucle para incluir Series
Md31_Gráfica - 2
'Nombre de las Series
nom_ser = Array("T_00", "T_01", "T_02", "T_03", "T_04", "T_05", "T_06", "T_07", "T_12", "T_13",
"T_14", "T_15", "T_16", "T_17", "T_18", "T_19", "T_21", "T_22", "V_1", "V_2", "V_3", "V_4", "M_1",
"M_2", "M_3", "M_4", "INV", "I_MP", "I_FC", "AT", "SP", "AUT", "M_01", "M_06", "P_1")
n_ser = 0
col_f = 0
While col_f < 18
If Cells(1, 5 + col_f) = True Then
'Número de Series
n_ser = ActiveChart.SeriesCollection.Count
'Rangos de los Ejes X e Y
Set x_g = Range(Cells(x_if, y_if), Cells(x_if + n_fil_f - 1, y_if))
Set y_g = Range(Cells(x_if, y_if + col_f + 1), Cells(x_if + n_fil_f - 1, y_if + col_f +
1))
'Serie 1
If n_ser = 0 Then
ActiveSheet.ChartObjects("1 Gráfico").Activate
'ActiveChart.ChartType = xlXYScatter
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(n_ser + 1).Name = nom_ser(col_f)
ActiveChart.SeriesCollection(n_ser + 1).XValues = x_g
ActiveChart.SeriesCollection(n_ser + 1).Values = y_g
ActiveChart.SeriesCollection(n_ser + 1).MarkerStyle = 2
ActiveChart.SeriesCollection(n_ser + 1).MarkerSize = 5
'Formato Eje X
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = "h:mm;@"
'Borrar Título
ActiveSheet.ChartObjects("1 Gráfico").Activate
ActiveChart.HasTitle = False
'Quitar Bordes de la Gráfica
ActiveChart.ChartArea.Border.Color = RGB(255, 255, 255)
ActiveChart.Axes(xlValue).Border.Color = RGB(255, 255, 255)
End If
'Serie >= 1
If n_ser >= 1 Then
ActiveSheet.ChartObjects("1 Gráfico").Activate
'ActiveChart.ChartType = xlXYScatter
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(n_ser + 1).Name = nom_ser(col_f)
ActiveChart.SeriesCollection(n_ser + 1).XValues = x_g
ActiveChart.SeriesCollection(n_ser + 1).Values = y_g
ActiveChart.SeriesCollection(n_ser + 1).MarkerStyle = 2
ActiveChart.SeriesCollection(n_ser + 1).MarkerSize = 5
End If
End If
col_f = col_f + 1
Wend
'Mover la Gráfica a la Hoja GRAF
ActiveSheet.ChartObjects("1 Gráfico").Activate
ActiveChart.Location Where:=xlLocationAsObject, Name:="GRAF"
Sheets("GRAF").Select
'Nombre
Md31_Gráfica - 3
ActiveSheet.ChartObjects(1).Name = "1 Gráfico"
'Posición
ActiveSheet.ChartObjects("1 Gráfico").Activate
ActiveSheet.Shapes("1 Gráfico").IncrementLeft 63
ActiveSheet.Shapes("1 Gráfico").IncrementTop 56
'Tipo de Gráfica (otra vez, porque última serie pierde formato)
'ActiveChart.ChartType = xlXYScatter
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
Range("A1").Value = ind_f
Call M32_Bombas
End Sub
Md32_Bombas - 1
Sub M32_Bombas()
'Índice de la Hoja filtrada
Sheets("GRAF").Select
ind_f = Range("A1").Value
Sheets(ind_f).Select
'Fila y Columna de la 1ª Celda filtrada
Range([D6], [D65536].End(xlUp)).SpecialCells(xlCellTypeVisible).Item(1).Select
x_if = ActiveCell.Row
y_if = ActiveCell.Column
'Nº Filas del filtrado
n_fil_f = Range([D6], [D65536].End(xlUp)).SpecialCells(xlCellTypeVisible).Rows.Count
'Añadir Gráfica
Sheets(ind_f).Select
ActiveSheet.Shapes.AddChart.Select
'Tipo de Gráfica
ActiveChart.ChartType = xlXYScatter
'Nombre
ActiveSheet.ChartObjects(1).Name = "2 Gráfico"
'Tamaño
ActiveSheet.ChartObjects("2 Gráfico").Width = 800
ActiveSheet.ChartObjects("2 Gráfico").Height = 200
'Leyenda
ActiveSheet.ChartObjects("2 Gráfico").Activate
ActiveChart.Legend.Select
Selection.Position = xlTop
'Borrar Series que aparecen por defecto
n_ser = ActiveChart.SeriesCollection.Count
While n_ser <> 0
ActiveChart.SeriesCollection(n_ser).Delete
n_ser = n_ser - 1
Wend
'Bucle para incluir Series
'Nombre de las Series
nom_ser = Array("T_00", "T_01", "T_02", "T_03", "T_04", "T_05", "T_06", "T_07", "T_12", "T_13",
"T_14", "T_15", "T_16", "T_17", "T_18", "T_19", "T_21", "T_22", "V_1", "V_2", "V_3", "V_4", "M_1",
"M_2", "M_3", "M_4", "INV", "I_MP", "I_FC", "AT", "SP", "AUT", "M_01", "M_06", "P_1")
n_ser = 0
col_f = 0
While col_f < 16
If Cells(1, 5 + col_f + 18) = True Then
'Número de Series
n_ser = ActiveChart.SeriesCollection.Count
'Rangos de los Ejes X e Y
Set x_g = Range(Cells(x_if, y_if), Cells(x_if + n_fil_f - 1, y_if))
Set y_g = Range(Cells(x_if, y_if + col_f + 19), Cells(x_if + n_fil_f - 1, y_if + col_f
+ 19))
'Serie 1
If n_ser = 0 Then
ActiveSheet.ChartObjects("2 Gráfico").Activate
ActiveChart.ChartType = xlXYScatter
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(n_ser + 1).Name = nom_ser(col_f + 18)
ActiveChart.SeriesCollection(n_ser + 1).XValues = x_g
ActiveChart.SeriesCollection(n_ser + 1).Values = y_g
ActiveChart.SeriesCollection(n_ser + 1).MarkerStyle = 1
ActiveChart.SeriesCollection(n_ser + 1).MarkerSize = 3
Md32_Bombas - 2
'Formato Eje X
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = "h:mm;@"
'Borrar Título
ActiveSheet.ChartObjects("2 Gráfico").Activate
ActiveChart.HasTitle = False
'Quitar Bordes de la Gráfica
ActiveChart.ChartArea.Border.Color = RGB(255, 255, 255)
ActiveChart.Axes(xlValue).Border.Color = RGB(255, 255, 255)
End If
'Serie >= 1
If n_ser >= 1 Then
ActiveSheet.ChartObjects("2 Gráfico").Activate
ActiveChart.ChartType = xlXYScatter
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(n_ser + 1).Name = nom_ser(col_f + 18)
ActiveChart.SeriesCollection(n_ser + 1).XValues = x_g
ActiveChart.SeriesCollection(n_ser + 1).Values = y_g
ActiveChart.SeriesCollection(n_ser + 1).MarkerStyle = 1
ActiveChart.SeriesCollection(n_ser + 1).MarkerSize = 3
End If
End If
col_f = col_f + 1
Wend
'Mover la Gráfica a la Hoja GRAF
ActiveSheet.ChartObjects("2 Gráfico").Activate
ActiveChart.Location Where:=xlLocationAsObject, Name:="GRAF"
Sheets("GRAF").Select
'Nombre
ActiveSheet.ChartObjects(2).Name = "2 Gráfico"
'Posición
ActiveSheet.ChartObjects("2 Gráfico").Activate
ActiveSheet.Shapes("2 Gráfico").IncrementLeft 63
ActiveSheet.Shapes("2 Gráfico").IncrementTop 460
'Tipo de Gráfica (otra vez, porque última serie pierde formato)
ActiveChart.ChartType = xlXYScatter
Range("A1").Select
Call M33_Presión
End Sub
Md33_Presión - 1
Sub M33_Presión()
'Índice de la Hoja filtrada
Sheets("GRAF").Select
ind_f = Range("A1").Value
Sheets(ind_f).Select
'Fila y Columna de la 1ª Celda filtrada
Range([D6], [D65536].End(xlUp)).SpecialCells(xlCellTypeVisible).Item(1).Select
x_if = ActiveCell.Row
y_if = ActiveCell.Column
'Nº Filas del filtrado
n_fil_f = Range([D6], [D65536].End(xlUp)).SpecialCells(xlCellTypeVisible).Rows.Count
'Añadir Gráfica
Sheets(ind_f).Select
ActiveSheet.Shapes.AddChart.Select
'Tipo de Gráfica
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
'Nombre
ActiveSheet.ChartObjects(1).Name = "3 Gráfico"
'Tamaño
ActiveSheet.ChartObjects("3 Gráfico").Width = 800
ActiveSheet.ChartObjects("3 Gráfico").Height = 150
'Leyenda
ActiveSheet.ChartObjects("3 Gráfico").Activate
ActiveChart.Legend.Select
Selection.Position = xlTop
'Borrar Series que aparecen por defecto
n_ser = ActiveChart.SeriesCollection.Count
While n_ser <> 0
ActiveChart.SeriesCollection(n_ser).Delete
n_ser = n_ser - 1
Wend
'Bucle para incluir Series
'Nombre de las Series
nom_ser = Array("T_00", "T_01", "T_02", "T_03", "T_04", "T_05", "T_06", "T_07", "T_12", "T_13",
"T_14", "T_15", "T_16", "T_17", "T_18", "T_19", "T_21", "T_22", "V_1", "V_2", "V_3", "V_4", "M_1",
"M_2", "M_3", "M_4", "INV", "I_MP", "I_FC", "AT", "SP", "AUT", "M_01", "M_06", "P_1")
n_ser = 0
col_f = 0
While col_f < 1
If Cells(1, 5 + col_f + 34) = True Then
'Número de Series
n_ser = ActiveChart.SeriesCollection.Count
'Rangos de los Ejes X e Y
Set x_g = Range(Cells(x_if, y_if), Cells(x_if + n_fil_f - 1, y_if))
Set y_g = Range(Cells(x_if, y_if + col_f + 35), Cells(x_if + n_fil_f - 1, y_if + col_f
+ 35))
'Serie 1
If n_ser = 0 Then
ActiveSheet.ChartObjects("3 Gráfico").Activate
ActiveChart.ChartType = xlXYScatter
'ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(n_ser + 1).Name = nom_ser(col_f + 34)
ActiveChart.SeriesCollection(n_ser + 1).XValues = x_g
ActiveChart.SeriesCollection(n_ser + 1).Values = y_g
ActiveChart.SeriesCollection(n_ser + 1).MarkerStyle = 1
Md33_Presión - 2
ActiveChart.SeriesCollection(n_ser + 1).MarkerSize = 3
ActiveChart.Axes(xlValue).DisplayUnit = xlHundreds
ActiveChart.Axes(xlValue).HasDisplayUnitLabel = False
ActiveChart.Axes(xlValue).MinimumScale = 0
ActiveChart.Axes(xlValue).MaximumScale = 400
ActiveChart.Axes(xlValue).MinorUnit = 10
'Formato Eje X
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.NumberFormat = "h:mm;@"
'Borrar Título
ActiveSheet.ChartObjects("3 Gráfico").Activate
ActiveChart.HasTitle = False
'Quitar Bordes de la Gráfica
ActiveChart.ChartArea.Border.Color = RGB(255, 255, 255)
ActiveChart.Axes(xlValue).Border.Color = RGB(255, 255, 255)
End If
'Serie >= 1
If n_ser >= 1 Then
ActiveSheet.ChartObjects("3 Gráfico").Activate
ActiveChart.ChartType = xlXYScatter
'ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(n_ser + 1).Name = nom_ser(col_f + 34)
ActiveChart.SeriesCollection(n_ser + 1).XValues = x_g
ActiveChart.SeriesCollection(n_ser + 1).Values = y_g
ActiveChart.SeriesCollection(n_ser + 1).MarkerStyle = 1
ActiveChart.SeriesCollection(n_ser + 1).MarkerSize = 3
ActiveChart.Axes(xlValue).DisplayUnit = xlHundreds
ActiveChart.Axes(xlValue).HasDisplayUnitLabel = False
ActiveChart.Axes(xlValue).MinimumScale = 0
ActiveChart.Axes(xlValue).MaximumScale = 400
ActiveChart.Axes(xlValue).MinorUnit = 10
End If
End If
col_f = col_f + 1
Wend
'Mover la Gráfica a la Hoja GRAF
ActiveSheet.ChartObjects("3 Gráfico").Activate
ActiveChart.Location Where:=xlLocationAsObject, Name:="GRAF"
Sheets("GRAF").Select
'Nombre
ActiveSheet.ChartObjects(3).Name = "3 Gráfico"
'Posición
ActiveSheet.ChartObjects("3 Gráfico").Activate
ActiveSheet.Shapes("3 Gráfico").IncrementLeft 63
ActiveSheet.Shapes("3 Gráfico").IncrementTop 660
'Tipo de Gráfica (otra vez, porque última serie pierde formato)
ActiveChart.ChartType = xlXYScatter
'ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
Range("A1").Select
Application.ScreenUpdating = True
Call M11_Registro
End Sub
ThisWorkbook - 1
Private Sub Workbook_Open()
'Actualizar - NO BORRAR
ActiveWorkbook.RefreshAll
'Índice de Hojas del Libro Excel
Sheets("GRAF").Activate
Dim PivotCell As Range, Tmp As Range
Set PivotCell = [BA6]
With PivotCell
.EntireColumn.ClearContents: .FormulaR1C1 = "MES"
.HorizontalAlignment = xlCenter
End With
For Each hoja In Application.Sheets
If ActiveSheet.Name = hoja.Name Then GoTo Loop1
Set Tmp = PivotCell.Offset(200, 0).End(xlUp).Offset(1, 0)
Tmp = hoja.Name
Loop1:
Next hoja
PivotCell.EntireColumn.AutoFit
Set Tmp = Nothing
Set PivotCell = Nothing
'Columns("BA:BA").Select
'Selection.EntireColumn.Hidden = True
Range("E1").Select
Range("A1").Select
'Ir a Hoja Última
Sheets(Sheets.Count).Select
End Sub
Descargar