Está en la página 1de 21

Sub Activar_Macros()

'CREANDO HOJA DE CONTROL


Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Select
Sheets(Sheets.Count).Name = "Hola"
Sheets("Hola").Move Before:=Sheets(1)
Sheets("Hola").Select

Call MENSAJES

End Sub

Sub MENSAJES()

'CREANDO FORMATOS DE HOJA


ActiveWindow.DisplayGridlines = False
Range("B2").Value = "HOLA BUENOS D�AS, MI CREADOR JES�S RENGEL, ME HA PROGRAMADO
PARA EJECUTAR UNA B�SQUEDA DENTRO DE LAS HOJAS DE ESTE EXCEL"
Range("B3").Value = "ESTA B�SQUEDA COSTA DE REGISTRAR TODA LAS PARTIDAS DE UN
PRESUPUESTO Y OBTENER EL TOTAL DE:"

Range("B5").Value = "MATERIALES"
Range("B6").Value = "EQUIPOS"
Range("B7").Value = "MANO DE OBRA"
Range("B8").Value = "GASTOS ADMINISTRATIVOS DE OBRA"
Range("B9").Value = "UTILIDADES"

Range("B11").Value = "PERO MI CREADOR ME PERMITI� DARTE LA OPCI�N DE ELEGIR DENTRO


DE ESTAS DOS OPCIONES"
Range("B13").Value = "EL REGISTRO ESPECIFICO, QUE TE DAR� UN PANORAMA DETALLADO DE
CADA PARTIDA Y CUANTO SE DISTRIBUYE DEL PRESUPUESTO"
Range("B14").Value = "EL REGISTRO GLOBAL QUE TE ARROJA UN CUADRO RESUMEN, DE LA
DISTRIBUCI�N"

Range("B16").Value = "PRESIONE CUALQUIERA DE LOS BOTONES DE B�SQUEDA, Y EMPEZARE A


REGISTRAR"
Range("B20").Value = "UNA COSA M�S MI REGISTRO DEPENDE DE ENCONTRAR PALABRAS CLAVE
DENTRO DE LAS HOJAS Y COMO SOY MUY PERFECCIONISTA, BUSCARE LA PALABRA EXACTA"
Range("B21").Value = "CONTANDO: MAY�SCULAS, MIN�SCULAS, ESPACIOS Y ACENTOS."
Range("B22").Value = " EN LAS CELDAS C24 APARECER�N LAS PALABRAS CLAVE QUE BUSCARE
POR DEFECTO EN REGISTRO GLOBAL SI NECESITA MODIFICARLAS, BUSCARE ESA PALABA DENTRO
DE LAS HOJAS"

Range("C24").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,


0)
Range("C24").Value = "Total Materiales:"

Range("C25").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,


0)
Range("C25").Value = "Total Equipos:"

Range("C26").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,


0)
Range("C26").Value = "SubTotal Mano de Obra:"

Range("C27").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,


0)
Range("C27").Value = "Administraci�n y Gastos Generales:"
Range("G24").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,
0)
Range("G24").Value = "MATERIALES"

Range("G25").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,


0)
Range("G25").Value = "EQUIPOS"

Range("G26").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,


0)
Range("G26").Value = "MANO DE OBRA"

Range("G27").BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0, 0,


0)
Range("G27").Value = "Prestaciones Sociales:"

Range("A30").Value = "HOJAS DEL LIBRO"

Call BOTON_GLOBAL
Call BOTON_ESPECIFICO

End Sub
Sub NOMBRE_PARTIDAS()

Dim X As Integer
Dim Y As Integer
Dim T As Integer ' HUMERO DE VECES QUE SE REPITE LA MACROS
Dim TJ As Integer ' VALOR UNICIAL DEL CICLO
Dim TJR As Integer 'CONDICION DE EJECUCON
Dim N_HOJA As String

Y = 1
X = 31
T = 23100 ' limite 150 pertidas
TJ = 1
Sheets("Hola").Select

For TJ = 1 To T
If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
TJR = Cells(1, 1).Value
If TJR = 1 Then
ActiveSheet.Next.Select
Else
N_HOJA = ActiveSheet.Name
Cells(1, 1).Value = 1
Sheets("Hola").Select
Cells(X, Y).Value = N_HOJA
X = X + 1
ActiveSheet.Next.Select
End If
Else
TJ = 23100
End If
Next

Sheets(Sheets.Count).Select
N_HOJA = ActiveSheet.Name
Sheets("Hola").Select
Cells(X, Y).Value = N_HOJA
T = 23100
TJ = 1
Sheets("Hola").Select

For TJ = 1 To T
If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
Cells(1, 1).Value = ""
ActiveSheet.Next.Select
Else
TJ = 23100
End If
Next

Sheets("Hola").Select

End Sub

Sub CONSOLIDADO()

Dim J As Integer
Dim J1 As Integer
Dim X As Integer
Dim Y As Integer
Dim XW As Integer
Dim YW As Integer
Dim CONSOLIDADOXY As String
Dim X1 As Integer
Dim Y1 As Integer
Dim CHEQUEO As Integer
Dim MATERIALES2 As Double
Dim EQUIPOS2 As Double
Dim COSTO_EQUIPO2 As Double
Dim TOTAL_JORNAL2 As Double
Dim TOTAL_BONO2 As Double
Dim TOTAL_PRESTACIONES2 As Double
Dim GASTOS_ADMINISTRATIVOS2 As Double
Dim UTILIDADES2 As Double
Dim UNITARIO2 As Double
Dim RENDIMENTO2 As Double
Dim CANTIDAD2 As Double

Dim palabraB10 As String


Dim palabraB20 As String
Dim palabraB30 As String
Dim palabraB40 As String

Sheets("Hola").Select
palabraB10 = Range("C24").Value
palabraB20 = Range("C25").Value
palabraB30 = Range("C26").Value
palabraB40 = Range("C27").Value

Call NOMBRE_PARTIDAS

'COMPROBANDO SI EXISTE HOJA CONSOLIDADO


Sheets("Hola").Select
XW = 31
YW = 1
CONSOLIDADOXY = ""
Cells(XW, YW).Select

Do While ActiveCell <> Empty


CONSOLIDADOXY = Cells(XW, YW).Value
If CONSOLIDADOXY = "CONSOLIDADO" Then
Sheets("CONSOLIDADO").Select
ActiveWindow.SelectedSheets.Delete
End If
XW = XW + 1
Cells(XW, YW).Select
Loop

'creando hoja
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Select
Sheets(Sheets.Count).Name = "CONSOLIDADO"

Sheets("Hola").Select

MATERIALES2 = 0
EQUIPOS2 = 0
COSTO_EQUIPO2 = 0
TOTAL_JORNAL2 = 0
TOTAL_BONO2 = 0
TOTAL_PRESTACIONES2 = 0
GASTOS_ADMINISTRATIVOS2 = 0
UTILIDADES2 = 0
UNITARIO2 = 0
RENDIMENTO2 = 0
CANTIDAD2 = 0

CHEQUEO = 0
' VRIFICAL SI LAS HOJA DE MATERIALES EXISTE
X = 11
Y = 11
X1 = 10
Y1 = 2
XW = 31
YW = 1
CONSOLIDADOXY = ""
Cells(XW, YW).Select
Do While ActiveCell <> Empty
CONSOLIDADOXY = Cells(XW, YW).Value
If CONSOLIDADOXY = "Materiales" Then
Sheets("Materiales").Select
Cells(1, 1).Value = 1
End If
XW = XW + 1
Cells(XW, YW).Select
Loop

' VRIFICAL SI LAS HOJA DE EQUIPO EXISTE


X = 11
Y = 11
X1 = 10
Y1 = 2
XW = 31
YW = 1
CONSOLIDADOXY = ""
Cells(XW, YW).Select
Do While ActiveCell <> Empty
CONSOLIDADOXY = Cells(XW, YW).Value
If CONSOLIDADOXY = "Equipos" Then
Sheets("Equipos").Select
Cells(1, 1).Value = 1
End If
XW = XW + 1
Cells(XW, YW).Select
Loop

' VRIFICAL SI LAS HOJA DE MANO DE OBRA EXISTE


X = 11
Y = 11
X1 = 10
Y1 = 2
XW = 31
YW = 1
CONSOLIDADOXY = ""
Cells(XW, YW).Select
Do While ActiveCell <> Empty
CONSOLIDADOXY = Cells(XW, YW).Value
If CONSOLIDADOXY = "Mano de Obra" Then
Sheets("Mano de Obra").Select
Cells(1, 1).Value = 1
End If
XW = XW + 1
Cells(XW, YW).Select
Loop

J = 1
J1 = 23100
Sheets("Partida 1").Select

For J = 1 To J1

'PRIMERA PREGUNTA:ESTA HOJA ES DIFERENTE A LA ULTIMA HOJA


If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
CHEQUEO = Cells(1, 1).Value
Cells(1, 1).Select
'SEGUNDA PREGUNTA:ESTA HOJA ESTA MARCAA EN A1 CON EL VALOR 1
If CHEQUEO = 1 Then
ActiveSheet.Next.Select
Else
'MATERIALES
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''
Dim palabra10 As String
Dim C10 As Integer
Dim FIN10 As Integer
Dim X10 As Integer
Dim Y10 As Integer
Dim D10 As Integer
Dim MATERIALES10 As Double
'DEFINIENDO VARIABLES
D10 = 1 'VERIFICADOR DE PROGRAMA
X10 = 11 'NUMERO DE CALDA HORIZOLTAL (INICIO DE CELDA)
Y10 = 6 ' NUMERO DE CELDA VERTICAL (INICIO DE CELDA)
C10 = 1 ' VALOR INICIAL DEL CICLO (SIMPRE 1)
FIN10 = 70 ' VALOR FINAL DEL CICLO( NUMERO DETERMINADOPOR EL RANGO QUE SE DESEE
BUSCAR)
For C10 = 1 To FIN10

palabra10 = Cells(X10, Y10).Value


If palabra10 = palabraB10 Then
Cells(X10, Y10).Select
D10 = 2
Exit For
End If
X10 = X10 + 1
Next
Y10 = 8
MATERIALES10 = Cells(X10, Y10).Value
Cells(11, 11).Value = MATERIALES10
'EQUIPO
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''
Dim palabra20 As String
Dim C20 As Integer
Dim FIN20 As Integer
Dim X20 As Integer
Dim Y20 As Integer
Dim D20 As Integer
Dim EQUIPO20 As Double
Dim COSTO_EQUIPO20 As Double

'DEFINIENDO VARIABLES
D20 = 1 'VERIFICADOR DE PROGRAMA
X20 = 11 'NUMERO DE CALDA HORIZOLTAL (INICIO DE CELDA)
Y20 = 6 ' NUMERO DE CELDA VERTICAL (INICIO DE CELDA)
C20 = 1 ' VALOR INICIAL DEL CICLO (SIMPRE 1)
FIN20 = 70 ' VALOR FINAL DEL CICLO( NUMERO DETERMINADOPOR EL RANGO QUE SE DESEE
BUSCAR)
For C20 = 1 To FIN20

palabra20 = Cells(X20, Y20).Value


If palabra20 = palabraB20 Then
Cells(X20, Y20).Select
D20 = 2
Exit For
End If
X20 = X20 + 1
Next
Y20 = 8
EQUIPOS20 = Cells(X20, Y20).Value
X20 = X20 + 1
COSTO_EQUIPO20 = Cells(X20, Y20).Value
Cells(12, 11).Value = EQUIPOS20
Cells(13, 11).Value = COSTO_EQUIPO20

'MANO DE
OBRA'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''
Dim palabra30 As String
Dim C30 As Integer
Dim FIN30 As Integer
Dim X30 As Integer
Dim Y30 As Integer
Dim D30 As Integer
Dim TOTAL_JORNAL30 As Double
Dim TOTAL_BONO30 As Double
Dim TOTAL_PRESTACIONES30 As Double
'DEFINIENDO VARIABLES
D30 = 1 'VERIFICADOR DE PROGRAMA
X30 = 11 'NUMERO DE CALDA HORIZOLTAL (INICIO DE CELDA)
Y30 = 4 ' NUMERO DE CELDA VERTICAL (INICIO DE CELDA)
C30 = 1 ' VALOR INICIAL DEL CICLO (SIMPRE 1)
FIN30 = 70 ' VALOR FINAL DEL CICLO( NUMERO DETERMINADOPOR EL RANGO QUE SE DESEE
BUSCAR)

For C30 = 1 To FIN30

palabra30 = Cells(X30, Y30).Value


If palabra30 = palabraB30 Then
Cells(X30, Y30).Select
D30 = 2
Exit For
End If
X30 = X30 + 1
Next
Y30 = 7
'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))7
TOTAL_JORNAL30 = Cells(X30, Y30).Value
Y30 = 8
TOTAL_BONO30 = Cells(X30, Y30).Value
X30 = X30 + 1
Y30 = 7

TOTAL_PRESTACIONES30 = Cells(X30, Y30).Value

Cells(14, 11).Value = TOTAL_JORNAL30


Cells(15, 11).Value = TOTAL_BONO30
Cells(16, 11).Value = TOTAL_PRESTACIONES30

'ADMINISTRATIVO
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''
Dim palabra40 As String
Dim C40 As Integer
Dim FIN40 As Integer
Dim X40 As Integer
Dim Y40 As Integer
Dim D40 As Integer
Dim GASTOS_ADMINISTRATIVOS40 As Double
Dim UTILIDADES40 As Double
Dim UNITARIO40 As Double
Dim RENDIMENTO40 As Double
Dim CANTIDAD40 As Double
'DEFINIENDO VARIABLES
D40 = 1 'VERIFICADOR DE PROGRAMA
X40 = 11 'NUMERO DE CALDA HORIZOLTAL (INICIO DE CELDA)
Y40 = 4 ' NUMERO DE CELDA VERTICAL (INICIO DE CELDA)
C40 = 1 ' VALOR INICIAL DEL CICLO (SIMPRE 1)
FIN40 = 70 ' VALOR FINAL DEL CICLO( NUMERO DETERMINADOPOR EL RANGO QUE SE DESEE
BUSCAR)
CANTIDAD40 = 0

For C40 = 1 To FIN40

palabra40 = Cells(X40, Y40).Value


If palabra40 = palabraB40 Then
Cells(X40, Y40).Select
D40 = 2
Exit For
End If
X40 = X40 + 1
Next
Y40 = 8
GASTOS_ADMINISTRATIVOS40 = Cells(X40, Y40).Value
X40 = X40 + 2
UTILIDADES40 = Cells(X40, Y40).Value
X40 = X40 + 7
UNITARIO40 = Cells(X40, Y40).Value
RENDIMENTO40 = Cells(8, 8).Value
CANTIDAD40 = Cells(9, 8).Value

Cells(17, 11).Value = GASTOS_ADMINISTRATIVOS40


Cells(18, 11).Value = UTILIDADES40
Cells(19, 11).Value = UNITARIO40
Cells(20, 11).Value = RENDIMENTO40
Cells(21, 11).Value = CANTIDAD40

'CONTUNUAR MACROS
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''
Cells(1, 1).Value = 1

MATERIALES2 = Cells(11, 11).Value


EQUIPOS2 = Cells(12, 11).Value
COSTO_EQUIPO2 = Cells(13, 11).Value
TOTAL_JORNAL2 = Cells(14, 11).Value
TOTAL_BONO2 = Cells(15, 11).Value
TOTAL_PRESTACIONES2 = Cells(16, 11).Value
GASTOS_ADMINISTRATIVOS2 = Cells(17, 11).Value
UTILIDADES2 = Cells(18, 11).Value
UNITARIO2 = Cells(19, 11).Value
RENDIMENTO2 = Cells(20, 11).Value
CANTIDAD2 = Cells(21, 11).Value

' RECOLECTANDO VALORES PARA PASARLOS A LA HPJA CONSOLIDADO

Sheets("CONSOLIDADO").Select
Range("B9:L9").Interior.Color = RGB(191, 191, 191)
'MENBRETE
Range("B9").Select
ActiveCell.FormulaR1C1 = "MATERIALES"
Range("C9").Select
ActiveCell.FormulaR1C1 = "EQUIPO"
Range("D9").Select
ActiveCell.FormulaR1C1 = "EQUIP/REND."
Range("E9").Select
ActiveCell.FormulaR1C1 = "JORNAL"
Range("F9").Select
ActiveCell.FormulaR1C1 = "BONO"
Range("G9").Select
ActiveCell.FormulaR1C1 = "F.C.A.S."
Range("H9").Select
ActiveCell.FormulaR1C1 = "GAST. ADM"
Range("I9").Select
ActiveCell.FormulaR1C1 = "UTILIDADES"
Range("J9").Select
ActiveCell.FormulaR1C1 = "APU"
Range("K9").Select
ActiveCell.FormulaR1C1 = "RENDIMIENTO"
Range("L9").Select
ActiveCell.FormulaR1C1 = "CANTIDAD"

'MENBRETE DE CONSOLIDADOS TOTALES


Range("N9:U9").Interior.Color = RGB(141, 180, 227)
Range("N9").Select
ActiveCell.FormulaR1C1 = "T.MATERIAL"
Range("O9").Select
ActiveCell.FormulaR1C1 = "T.EQUIPOS"
Range("P9").Select
ActiveCell.FormulaR1C1 = "T.JORNAL"
Range("Q9").Select
ActiveCell.FormulaR1C1 = "T.BONO"
Range("R9").Select
ActiveCell.FormulaR1C1 = "T. FCAS"
Range("S9").Select
ActiveCell.FormulaR1C1 = "T.MANO DE OBRA"
Range("T9").Select
ActiveCell.FormulaR1C1 = "T.GAST. ADM"
Range("U9").Select
ActiveCell.FormulaR1C1 = "T. UTILIDADES"

Range("B9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,


0, 0)
Range("C9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("D9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("E9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("F9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("G9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("H9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("I9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("J9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("K9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("L9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)

Range("N9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,


0, 0)
Range("O9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("P9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("Q9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("R9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("S9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("T9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)
Range("U9").BorderAround LineStyle:=xlContinuous, Weight:=xlMedium, Color:=RGB(0,
0, 0)

Y1 = 2
Cells(X1, Y1).Value = MATERIALES2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 3
Cells(X1, Y1).Value = EQUIPOS2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 4
Cells(X1, Y1).Value = COSTO_EQUIPO2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 5
Cells(X1, Y1).Value = TOTAL_JORNAL2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 6
Cells(X1, Y1).Value = TOTAL_BONO2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 7
Cells(X1, Y1).Value = TOTAL_PRESTACIONES2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 8
Cells(X1, Y1).Value = GASTOS_ADMINISTRATIVOS2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 9
Cells(X1, Y1).Value = UTILIDADES2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 10
Cells(X1, Y1).Value = UNITARIO2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 11
Cells(X1, Y1).Value = RENDIMENTO2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 12
Cells(X1, Y1).Value = CANTIDAD2
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
'CONSOLIDADO TOTAL DE OBRA
'MATERIALES
Y1 = 14
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-2]*RC[-12],2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)

'EQUIOS
Y1 = 15
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-3]*RC[-11],2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 16
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-4]*RC[-11]/RC[-5],2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 17
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-5]*RC[-11]/RC[-6],2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 18
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-6]*RC[-11]/RC[-7],2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 19
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND((RC[-3]+RC[-2]+RC[-1]),2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 20
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-8]*RC[-12],2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)
Y1 = 21
Cells(X1, Y1).Select
ActiveCell.FormulaR1C1 = "=ROUND(RC[-9]*RC[-12],2)"
Cells(X1, Y1).BorderAround LineStyle:=xlContinuous, Weight:=xlThin, Color:=RGB(0,
0, 0)

X1 = X1 + 1
Sheets("Partida 1").Select

End If
Else
J = 23100 'Exit For
End If
Next
'borrando marcas
J = 1
J1 = 340 'NUMERO DEVEES QUE SE REPITA LA MACROS
Sheets("Partida 1").Select
For J = 1 To J1
If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
Cells(1, 1).Value = ""
Columns("K:K").Select
Selection.Delete Shift:=xlToLeft
ActiveSheet.Next.Select
End If
Next

End Sub

Sub BOTON_GLOBAL()

ActiveSheet.Buttons.Add(63, 262, 175.5, 24.75).Select


Selection.OnAction = "CONSOLIDADO"
ActiveSheet.Shapes("Button 1").Select '''''''''''''''''''CAMBIAR A
UN''''''''''''''''''
Selection.Characters.Text = "REGISTRO GLOBAL"
Range("A18").Select
End Sub

Sub BOTON_ESPECIFICO()
'
' BOTON_ESPECIFICO Macro
'

'
ActiveSheet.Buttons.Add(300, 262, 175.5, 24.75).Select
Selection.OnAction = "CONSOLIDADO"
ActiveSheet.Shapes("Button 2").Select
Selection.Characters.Text = "REGISTRO ESPECIFICO"
Range("A18").Select
End Sub

Sub CONSOLIDADO_ESPESIFICO()

Dim X As Integer
Dim Y As Integer
Dim INICIO As Integer
Dim FINAL As Integer
Dim X2 As Integer
Dim Y2 As Integer
Dim C As Integer
Dim C2 As Integer ' VALOR DE REPETICION DEL CICLO
Dim T As Integer
Dim T2 As Integer ' VALOR DE REPETICION DEL CICLO
Dim PALABRA1 As String
Dim PALABRA2 As String

Dim Materiales As String


Dim Equipos As String
Dim Mano_de_obra As String
Dim Administrativo As String

Sheets("Hola").Select
Materiales = Range("G24").Value
Equipos = Range("G25").Value
Mano_de_obra = Range("G26").Value
Administrativo = Range("G27").Value

X2 = 11
INICIO = 1
FINAL = 20

C = 1
C2 = 60
T = 1
T2 = 8
PALABRA1 = ""
PALABRA2 = ""
Y = 2
X = 11
X2 = 11
Y2 = 10

For INICIO = 1 To FINAL

Call FORMULAX
' buscando
materiales'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''
For C = 1 To C2
PALABRA1 = Cells(X, Y).Value
If PALABRA1 = Materiales Then
Y2 = 10
Cells(X2, Y2).Value = Materiales
X2 = X2 + 1
X = X + 2
Cells(X, Y).Select
Do While ActiveCell <> Empty
Y = 1
Y2 = 10
For T = 1 To T2
Cells(X, Y).Select
Selection.Copy
Cells(X2, Y2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Y = Y + 1
Y2 = Y2 + 1
Next
Y = 1
X = X + 1
X2 = X2 + 1
Cells(X, Y).Select
Loop
Else
X = X + 1
End If
Next
X = 11
C = 1
C2 = 60
T = 1
T2 = 8
Y = 2
' buscando
equipos''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''
For C = 1 To C2
PALABRA1 = Cells(X, Y).Value

If PALABRA1 = Equipos Then


Y2 = 10
Cells(X2, Y2).Value = Equipos
X2 = X2 + 1
X = X + 2
Cells(X, Y).Select
Do While ActiveCell <> Empty
Y = 1
Y2 = 10
For T = 1 To T2
Cells(X, Y).Select
Selection.Copy
Cells(X2, Y2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Y = Y + 1
Y2 = Y2 + 1
Next
Y = 1
X = X + 1
X2 = X2 + 1
Cells(X, Y).Select
Loop
Else
X = X + 1
End If
Next

X = 11
C = 1
C2 = 60
T = 1
T2 = 8
Y = 2
' buscando mano de
obra'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''
For C = 1 To C2
PALABRA1 = Cells(X, Y).Value

If PALABRA1 = Mano_de_obra Then


Y2 = 10
Cells(X2, Y2).Value = Mano_de_obra
X2 = X2 + 1
X = X + 2
Cells(X, Y).Select
Do While ActiveCell <> Empty
Y = 1
Y2 = 10
For T = 1 To T2
Cells(X, Y).Select
Selection.Copy
Cells(X2, Y2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Y = Y + 1
Y2 = Y2 + 1
Next
Y = 1
X = X + 1
X2 = X2 + 1
Cells(X, Y).Select
Loop
Else
X = X + 1
End If
Next

X = 11
C = 1
C2 = 60
T = 1
T2 = 8
Y = 4
' buscando mano de
obra'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''
For C = 1 To C2
PALABRA1 = Cells(X, Y).Value

If PALABRA1 = Administrativo Then


Y2 = 10
Cells(X2, Y2).Value = Administrativo
X2 = X2 + 1
'F.C.A.S
Cells(X, 3).Select
Selection.Copy
Cells(X2, 10).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells(X, 4).Select
Selection.Copy
Cells(X2, 11).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells(X, 7).Select
Selection.Copy
Cells(X2, 17).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'GASTOS ADMINISTRATIVOS
X2 = X2 + 1
X = X + 5
Cells(X, 3).Select
Selection.Copy
Cells(X2, 10).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells(X, 4).Select
Selection.Copy
Cells(X2, 11).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells(X, 8).Select
Selection.Copy
Cells(X2, 17).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'UTILIDADES
X2 = X2 + 1
X = X + 2
Cells(X, 5).Select
Selection.Copy
Cells(X2, 10).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells(X, 6).Select
Selection.Copy
Cells(X2, 11).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells(X, 8).Select
Selection.Copy
Cells(X2, 17).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'TOTAL SIN IMPUESTOS


X2 = X2 + 1
X = X + 3
Cells(X, 4).Select
Selection.Copy
Cells(X2, 10).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Cells(X, 8).Select
Selection.Copy
Cells(X2, 17).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Else
X = X + 1
End If
Next

'camio de
hoja'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''
If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
Y = 2
X = 11
X2 = 11
Y2 = 10
ActiveSheet.Next.Select
Else
Exit For
End If
Next

End Sub

Sub borrar()
Dim Incioz As Integer
Dim Finalz As Integer

Sheets("Partida 1").Select
Incioz = 1
Finalz = 13

For inicioz = 1 To Finalz


If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
Columns("J:Q").Select
Selection.ClearContents
ActiveSheet.Next.Select
End If
Next
Sheets(Sheets.Count).Select
Columns("J:Q").Select
Selection.ClearContents
End Sub

Sub FORMULAX()

Range("J8").Select
ActiveCell.FormulaR1C1 = "=R[-3]C[-5]&"" ""&R[-3]C[-4]"
Range("J9").Select
ActiveCell.FormulaR1C1 = "=R[-3]C[-7]"
Range("J10").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[-8]"
Range("K10").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[-8]"
Range("L10").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[-7]"
Range("M10").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[-7]"
Range("N10").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[-7]"
Range("O10").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[-7]"
Range("P10").Select
ActiveCell.FormulaR1C1 = "=R[-2]C[-9]"
Range("Q10").Select
ActiveCell.FormulaR1C1 = "=R[-2]C[-9]"
Range("Q11").Select
End Sub
Sub CONSOLIDO_ESPECIFO_HOJA()
Dim X As Integer
Dim Y As Integer
Dim X2 As Integer
Dim Y2 As Integer

Dim C1 As Integer
Dim C2 As Integer

Dim N�P As String


Dim DESCRIPCION As String
Dim CODIGO As String
Dim UNIDAD As String
Dim CANTIDAD As String
Dim RENDIMIENTO As String

Dim ITEN As Integer

Dim CODIGO_MAERIALES As String


Dim DESCRIP_MATERIALES As String
Dim UNIDAD_MATERILES As String
Dim CANTIDAD_MATERIALES As Double
Dim DESPERDICIO As Double
Dim PRECIO_MATERIALES As Double

Dim CODIGO_EQUIPO As String


Dim DESCRIP_EQUIPO As String
Dim CANTIDAD_EQUIPO As Double
Dim COP As Double
Dim PRECIO_EQUIPO As Double

Dim CODIGO_MANO As String


Dim DESCRIP_MANO As String
Dim CANTIDAD_MANO As Double
Dim JORNAL As Double
Dim BONO As Double

Dim PORCENTAJE_FCAS As Double


Dim PORCENTAJE_ADM As Double
Dim PORCENTAJE_UTILIDAD As Double

Dim XW As Integer
Dim YW As Integer
Dim CONSOLIDADOXY As String
Dim TESTIGO As Integer

Dim Mat As String


Dim Equi As String
Dim Man_Obra As String
Dim Adm As String
'DEFINIR VARIALES
C1 = 1
C2 = 340

X2 = 7
Y2 = 13

X = 3
Y = 2

ITEN = 1
'INCIO DE PROGRAMA
Call CONSOLIDADO_ESPESIFICO

Sheets("Hola").Select
Mat = Range("G24").Value
Equi = Range("G25").Value
Man_Obra = Range("G26").Value
Adm = Range("G27").Value

'COMPROBANDO SI EXISTE HOJA CONSOLIDADO


Sheets("Hola").Select
XW = 31
YW = 1
CONSOLIDADOXY = ""
Cells(XW, YW).Select

Do While ActiveCell <> Empty


CONSOLIDADOXY = Cells(XW, YW).Value
If CONSOLIDADOXY = "CONSOLIDADO" Then
Sheets("CONSOLIDADO").Select
ActiveWindow.SelectedSheets.Delete
End If
XW = XW + 1
Cells(XW, YW).Select
Loop

'Creando hoja
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Select
Sheets(Sheets.Count).Name = "CONSOLIDADO"
Sheets("Hola").Select
If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
ActiveSheet.Next.Select
End If

Sheets("Partida 1").Select
'COMIENSO DE COPIADO
For C1 = 1 To C2
TESTIGO = Cells(1, 1).Value
If TESTIGO <> 1 Then
Cells(1, 1).Value = 1
Range("J8:Q60").Select
Selection.Copy
Sheets("CONSOLIDADO").Select
Range("M3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

N�P = Range("M3").Value
DESCRIPCION = Range("M4").Value
CODIGO = Range("N5").Value
UNIDAD = Range("P5").Value
CANTIDAD = Range("R5").Value
RENDIMIENTO = Range("T5").Value

Cells(X, Y).Value = N�P


X = X + 1
Cells(X, Y).Value = DESCRIPCION
X = X + 1
Cells(X, Y).Value = "C�digo:"
Y = 3
Cells(X, Y).Value = CODIGO
Y = 4
Cells(X, Y).Value = "Unidad:"
Y = 5
Cells(X, Y).Value = UNIDAD
Y = 2
X = X + 1

'mteriales'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''
Cells(X, Y).Value = "Materiales"
X = X + 1
Cells(X, Y).Value = "Iten"
Y = 3
Cells(X, Y).Value = "C�digo"
Y = 4
Cells(X, Y).Value = "Descripci�n"
Y = 5
Cells(X, Y).Value = "Unidad"
Y = 6
Cells(X, Y).Value = "Cantidad"
Y = 7
Cells(X, Y).Value = "Desperdicio"
Y = 8
Cells(X, Y).Value = "Precio"
Y = 9
Cells(X, Y).Value = "Total"
Y = 2
X = X + 1
Cells(X2, Y2).Select
Do While ActiveCell <> Empty
CODIGO_MAERIALES = Cells(X2, Y2).Value
Y2 = 14
ITEN = Cells(X2, Y2).Value
Y2 = 15
DESCRIP_MATERIALES = Cells(X2, Y2).Value
Y2 = 16
UNIDAD_MATERILES = Cells(X2, Y2).Value
Y2 = 17
CANTIDAD_MATERIALES = Cells(X2, Y2).Value
Y2 = 18
DESPERDICIO = Cells(X2, Y2).Value
Y2 = 19
PRECIO_MATERIALES = Cells(X2, Y2).Value
'colocando materiles
Y = 2
Cells(X, Y).Value = ITEN
Y = 3
Cells(X, Y).Value = CODIGO_MAERIALES
Y = 4
Cells(X, Y).Value = DESCRIP_MATERIALES
Y = 5
Cells(X, Y).Value = UNIDAD_MATERILES
Y = 6
Cells(X, Y).Value = CANTIDAD_MATERIALES
Y = 7
Cells(X, Y).Value = DESPERDICIO
Y = 8
Cells(X, Y).Value = PRECIO_MATERIALES
ITEN = ITEN + 1
X = X + 1
X2 = X2 + 1
Y2 = 13
Cells(X2, Y2).Select
Loop
ITEN = 1
Else
If ActiveSheet.Name <> Sheets(Sheets.Count).Name Then
ActiveSheet.Next.Select
X2 = 7
Y2 = 13
End If
End If
Next

End Sub

También podría gustarte