Você está na página 1de 10

Function Edad(Fecha_Nacimiento As Date) As Integer Edad = Int((Date - Fecha_Nacimiento) / 365.

25) End Function Function Promedio_Ponderado(Nota1, Nota2) Promedio_Ponderado = Nota1 * 0.4 + Nota2 * 0.6 End Function Function VerificaRUT(RUT) As String Dim N1, N2, N3, N4, N5, N6, N7, N8 As Integer Dim Suma As Integer, Difsuma As Integer

If Len(RUT) = 7 Then RUT = "0" & RUT End If N1 = Mid(RUT, 8, 1) * 2 N2 = Mid(RUT, 7, 1) * 3 N3 = Mid(RUT, 6, 1) * 4 N4 = Mid(RUT, 5, 1) * 5 N5 = Mid(RUT, 4, 1) * 6 N6 = Mid(RUT, 3, 1) * 7 N7 = Mid(RUT, 2, 1) * 2 N8 = Mid(RUT, 1, 1) * 3 Suma = N1 + N2 + N3 + N4 + N5 + N6 + N7 + N8 Difsuma = 11 - (Suma Mod 11) If Difsuma = 10 Then VerificaRUT = "K" ElseIf Difsuma = 11 Then VerificaRUT = 0 Else VerificaRUT = Difsuma End If End Function Function EnLetras(Valor, Optional ByVal Tipo As Byte = 1) As String ' Funcin Principal ' If Not IsNumeric(Valor) Then EnLetras = " La referencia no es valor o... 'excede' la precisin !!!": Exit Function End If: Dim Moneda As String, Fracs As String, Cents As Integer If Int(Abs(Valor)) = 1 Then Moneda = " peso.-" Else Moneda = " pesos.-"

If Right(Letras(Abs(Int(Valor))), 6) = "illn " Or Right(Letras(Abs(Int(Valor))), 8) = "illones " Then Moneda = "de" & Moneda Cents = Application.Round(Abs(Valor) - Int(Abs(Valor)), 2) * 100 If Cents = 1 Then Fracs = " centavo" Else Fracs = " centavos" If Cents = 0 Then Fracs = "" Else Fracs = " con " & Letras(Cents) & Fracs EnLetras = Letras(Int(Abs(Valor))) & Moneda & Fracs If Valor < 0 Then EnLetras = "menos " & EnLetras If Tipo = 2 Then EnLetras = UCase(EnLetras) ' TODO EN MAYUSCULAS ' If Tipo = 3 Then EnLetras = StrConv(EnLetras, vbProperCase) ' Todo Como Nombre Propio ' If Tipo = 4 Then EnLetras = UCase(Left(EnLetras, 1)) & Mid(EnLetras, 2) ' Primer letra en mayuscula SOLAMENTE ' EnLetras = "" & EnLetras & "" End Function Private Function Letras(Valor) As String ' Funcin Auxiliar [uso 'exclusivo' de la funcin 'principal'] ' Select Case Int(Valor) Case 0: Letras = "cero" Case 1: Letras = "un" Case 2: Letras = "dos" Case 3: Letras = "tres" Case 4: Letras = "cuatro" Case 5: Letras = "cinco" Case 6: Letras = "seis" Case 7: Letras = "siete" Case 8: Letras = "ocho" Case 9: Letras = "nueve" Case 10: Letras = "diez" Case 11: Letras = "once" Case 12: Letras = "doce" Case 13: Letras = "trece" Case 14: Letras = "catorce" Case 15: Letras = "quince" Case Is < 20: Letras = "dieci" & Letras(Valor - 10) Case 20: Letras = "veinte" Case Is < 30: Letras = "veinti" & Letras(Valor - 20) Case 30: Letras = "treinta" Case 40: Letras = "cuarenta" Case 50: Letras = "cincuenta" Case 60: Letras = "sesenta" Case 70: Letras = "setenta" Case 80: Letras = "ochenta" Case 90: Letras = "noventa" Case Is < 100: Letras = Letras(Int(Valor \ 10) * 10) & " y " & Letras(Valor Mod 10) Case 100: Letras = "cien" Case Is < 200: Letras = "ciento " & Letras(Valor - 100) Case 200, 300, 400, 600, 800: Letras = Letras(Int(Valor \ 100)) & "cientos" Case 500: Letras = "quinientos" Case 700: Letras = "setecientos"

Case 900: Letras = "novecientos" Case Is < 1000: Letras = Letras(Int(Valor \ 100) * 100) & " " & Letras(Valor Mod 100) Case 1000: Letras = "mil" Case Is < 2000: Letras = "mil " & Letras(Valor Mod 1000) Case Is < 1000000: Letras = Letras(Int(Valor \ 1000)) & " mil" If Valor Mod 1000 Then Letras = Letras & " " & Letras(Valor Mod 1000) Case 1000000: Letras = "un milln " Case Is < 2000000: Letras = "un milln " & Letras(Valor Mod 1000000) Case Is < 1000000000000#: Letras = Letras(Int(Valor / 1000000)) & " millones " If (Valor - Int(Valor / 1000000) * 1000000) _ Then Letras = Letras & Letras(Valor - Int(Valor / 1000000) * 1000000) Case 1000000000000#: Letras = "un billn " Case Is < 2000000000000# Letras = "un billn " & Letras(Valor - Int(Valor / 1000000000000#) * 1000000000000#) Case Else: Letras = Letras(Int(Valor / 1000000000000#)) & " billones " If (Valor - Int(Valor / 1000000000000#) * 1000000000000#) _ Then Letras = Letras & " " & Letras(Valor - Int(Valor / 1000000000000#) * 1000000000000#) End Select End Function

Sub Macro6() ' Macro6 Macro Sheets("Hoja3").Select If Range("A3").Value = "" Then MsgBox (" No hay Datos. Ingrese Rut") ElseIf Range("B3").Value = "" Then MsgBox (" No hay Datos. Ingrese Nombre") ElseIf Range("C3").Value = "" Then MsgBox (" No hay Datos. Ingrese Apellido") Else Range("A3:R3").Select Selection.Copy Sheets("Hoja1").Select Range("A2").Select Selection.End(xlDown).Select ActiveCell.Offset(1, 0).Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Range("A2").Select Selection.End(xlDown).Select ActiveCell.Offset(1, 0).Range("A1").Select ActiveCell.Offset(0, 11).Select Selection.NumberFormat = "m/d/yyyy" Sheets("Hoja3").Select Application.CutCopyMode = False

ActiveCell.Range("A1:C1").Select Selection.ClearContents ActiveCell.Offset(4, 3).Range("A1").Select Selection.ClearContents ActiveCell.Offset(7, 0).Range("A1").Select Selection.ClearContents ActiveCell.Offset(8, -1).Range("A1").Select Selection.ClearContents ActiveCell.Offset(-12, 3).Range("A1").Select Selection.ClearContents ActiveCell.Offset(9, 0).Range("A1").Select Selection.ClearContents End If End Sub

Sub Macro7() ' Macro7 Macro ActiveCell.Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.Copy Sheets("Hoja1").Select ActiveWindow.SmallScroll Down:=-36 ActiveCell.Offset(-59, -11).Range("A1").Select Selection.End(xlDown).Select Range("A56").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ActiveWindow.SmallScroll Down:=3 Range("A57").Select ActiveWindow.SmallScroll Down:=-27 Range("A2").Select Selection.End(xlDown).Select Range("K56").Select Application.CutCopyMode = False Selection.NumberFormat = "m/d/yyyy" ActiveWindow.SmallScroll Down:=12 Range("K60").Select Sheets("Hoja3").Select

Selection.ClearContents Range("D7").Select ActiveCell.FormulaR1C1 = "" Range("D14").Select ActiveCell.FormulaR1C1 = "" Range("E24").Select ActiveCell.FormulaR1C1 = "" Range("E26").Select ActiveCell.FormulaR1C1 = "" Range("E28").Select ActiveCell.FormulaR1C1 = "" Range("H26").Select ActiveCell.FormulaR1C1 = "" Range("B30").Select ActiveWindow.SmallScroll Down:=-39 Range("D5").Select ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 4 Range("O3").Select ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("A3").Select ActiveCell.FormulaR1C1 = "16666666" Range("B3").Select ActiveCell.FormulaR1C1 = "nsnnsns" Range("C3").Select ActiveCell.FormulaR1C1 = "sjjsjjsj" Range("D3").Select ActiveWindow.SmallScroll Down:=-12 Range("E24").Select ActiveCell.FormulaR1C1 = "555555" Range("E26").Select ActiveCell.FormulaR1C1 = "555" Range("E28").Select ActiveCell.FormulaR1C1 = "55" Range("H26").Select ActiveCell.FormulaR1C1 = "555" Range("J31").Select ActiveWindow.SmallScroll Down:=-30 Range("M4").Select ActiveCell.FormulaR1C1 = "=R[20]C[-8]" Range("N4").Select ActiveCell.FormulaR1C1 = "=R[22]C[-9]" Range("O4").Select ActiveCell.FormulaR1C1 = "=R[24]C[-10]" Range("O5").Select

ActiveWindow.SmallScroll Down:=-9 Range("H26").Select ActiveCell.FormulaR1C1 = "1" Range("M23").Select ActiveWindow.SmallScroll ToRight:=2 Range("O4").Select ActiveCell.FormulaR1C1 = "=R[20]C[-7]" Range("P4").Select ActiveCell.FormulaR1C1 = "=R[22]C[-8]" Range("P4").Select ActiveWindow.SmallScroll Down:=0 Range("O4").Select ActiveCell.FormulaR1C1 = "=R[24]C[-10]" Range("O5").Select ActiveWindow.SmallScroll Down:=-12 Range("O2").Select ActiveCell.FormulaR1C1 = "Ahorro Familia" Range("Q4").Select ActiveCell.FormulaR1C1 = "=R[24]C[-9]" Range("H28").Select ActiveCell.FormulaR1C1 = _ "=VLOOKUP(R[-25]C[1],Datos!R11C4:R15C5,2,0)*R[-4]C[-3]" Range("E24").Select ActiveCell.FormulaR1C1 = "55555555" Range("H28").Select ActiveCell.FormulaR1C1 = _ "=VLOOKUP(R[-25]C[1],Datos!R11C4:R15C5,2,0)*R[-4]C[-3]" Range("H29").Select ActiveWindow.SmallScroll Down:=-15 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("D3").Select ChDir "D:\Macros Abril Vespertino" ActiveWorkbook.SaveAs Filename:= _ "D:\Macros Abril Vespertino\Base de datos Empleados 2012 para controles Natalia (CLASE 77).xlsm" _ , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False ActiveSheet.Paste Range("D3").Select ActiveCell.FormulaR1C1 = "" Range("D3").Select ActiveSheet.Paste Range("D3").Select ActiveSheet.PasteSpecial Format:="Texto", Link:=False, DisplayAsIcon:= _ False Range("E3").Select ActiveSheet.PasteSpecial Format:="Texto", Link:=False, DisplayAsIcon:= _ False

Range("I3").Select ActiveSheet.PasteSpecial Format:="Texto", Link:=False, DisplayAsIcon:= _ False Range("E3").Select End Sub Sub Macro8() ' ' Macro8 Macro ' Range("A3:R3").Select Selection.Copy Sheets("Hoja1").Select Range("A58").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False End Sub

Sub Macro7() ' Macro7 Macro ActiveCell.Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.Copy Sheets("Hoja1").Select ActiveWindow.SmallScroll Down:=-36 ActiveCell.Offset(-59, -11).Range("A1").Select Selection.End(xlDown).Select Range("A56").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ActiveWindow.SmallScroll Down:=3 Range("A57").Select ActiveWindow.SmallScroll Down:=-27 Range("A2").Select Selection.End(xlDown).Select Range("K56").Select Application.CutCopyMode = False Selection.NumberFormat = "m/d/yyyy" ActiveWindow.SmallScroll Down:=12 Range("K60").Select Sheets("Hoja3").Select Selection.ClearContents Range("D7").Select

ActiveCell.FormulaR1C1 = "" Range("D14").Select ActiveCell.FormulaR1C1 = "" Range("E24").Select ActiveCell.FormulaR1C1 = "" Range("E26").Select ActiveCell.FormulaR1C1 = "" Range("E28").Select ActiveCell.FormulaR1C1 = "" Range("H26").Select ActiveCell.FormulaR1C1 = "" Range("B30").Select ActiveWindow.SmallScroll Down:=-39 Range("D5").Select ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 4 Range("O3").Select ActiveWindow.ScrollColumn = 3 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("A3").Select ActiveCell.FormulaR1C1 = "16666666" Range("B3").Select ActiveCell.FormulaR1C1 = "nsnnsns" Range("C3").Select ActiveCell.FormulaR1C1 = "sjjsjjsj" Range("D3").Select ActiveWindow.SmallScroll Down:=-12 Range("E24").Select ActiveCell.FormulaR1C1 = "555555" Range("E26").Select ActiveCell.FormulaR1C1 = "555" Range("E28").Select ActiveCell.FormulaR1C1 = "55" Range("H26").Select ActiveCell.FormulaR1C1 = "555" Range("J31").Select ActiveWindow.SmallScroll Down:=-30 Range("M4").Select ActiveCell.FormulaR1C1 = "=R[20]C[-8]" Range("N4").Select ActiveCell.FormulaR1C1 = "=R[22]C[-9]" Range("O4").Select ActiveCell.FormulaR1C1 = "=R[24]C[-10]" Range("O5").Select ActiveWindow.SmallScroll Down:=-9 Range("H26").Select

ActiveCell.FormulaR1C1 = "1" Range("M23").Select ActiveWindow.SmallScroll ToRight:=2 Range("O4").Select ActiveCell.FormulaR1C1 = "=R[20]C[-7]" Range("P4").Select ActiveCell.FormulaR1C1 = "=R[22]C[-8]" Range("P4").Select ActiveWindow.SmallScroll Down:=0 Range("O4").Select ActiveCell.FormulaR1C1 = "=R[24]C[-10]" Range("O5").Select ActiveWindow.SmallScroll Down:=-12 Range("O2").Select ActiveCell.FormulaR1C1 = "Ahorro Familia" Range("Q4").Select ActiveCell.FormulaR1C1 = "=R[24]C[-9]" Range("H28").Select ActiveCell.FormulaR1C1 = _ "=VLOOKUP(R[-25]C[1],Datos!R11C4:R15C5,2,0)*R[-4]C[-3]" Range("E24").Select ActiveCell.FormulaR1C1 = "55555555" Range("H28").Select ActiveCell.FormulaR1C1 = _ "=VLOOKUP(R[-25]C[1],Datos!R11C4:R15C5,2,0)*R[-4]C[-3]" Range("H29").Select ActiveWindow.SmallScroll Down:=-15 ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range("D3").Select ChDir "D:\Macros Abril Vespertino" ActiveWorkbook.SaveAs Filename:= _ "D:\Macros Abril Vespertino\Base de datos Empleados 2012 para controles Natalia (CLASE 77).xlsm" _ , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False ActiveSheet.Paste Range("D3").Select ActiveCell.FormulaR1C1 = "" Range("D3").Select ActiveSheet.Paste Range("D3").Select ActiveSheet.PasteSpecial Format:="Texto", Link:=False, DisplayAsIcon:= _ False Range("E3").Select ActiveSheet.PasteSpecial Format:="Texto", Link:=False, DisplayAsIcon:= _ False Range("I3").Select ActiveSheet.PasteSpecial Format:="Texto", Link:=False, DisplayAsIcon:= _

False Range("E3").Select End Sub Sub Macro8() ' Macro8 Macro Range("A3:R3").Select Selection.Copy Sheets("Hoja1").Select Range("A58").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False End Sub