Você está na página 1de 3

Sub Checksum() Sheets("Reporte_Unidades").Select ActiveWindow.SelectedSheets.

Delete Dim HojaActual As Worksheet Dim Fila As Integer Dim Columna As Integer Dim Cadena As String Dim Caracter As String Dim Pos As Long Dim Checksum As Integer Columna = 9 For Each HojaActual In Worksheets HojaActual.Select 'Freeze Panes ActiveWindow.FreezePanes = False 'Headings y Gridlines ActiveWindow.DisplayHeadings = True ActiveWindow.DisplayGridlines = True 'Borrar Encabezado Range("B2:F2").Select Selection.Delete Shift:=xlToLeft 'Insertar Columnas. Columns("D:D").Select Selection.Insert Shift:=xlToRight, Selection.Insert Shift:=xlToRight, Selection.Insert Shift:=xlToRight, Selection.Insert Shift:=xlToRight, Selection.Insert Shift:=xlToRight, 'Zoom 60%. ActiveWindow.Zoom = 60 'Mover dos columnas. Columns("J:K").Select Selection.Cut Destination:=Columns("D:E") 'Seleccionar Rango Range("I7:I1500").Select Selection.TextToColumns Destination:=Range("I7"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False , _ Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _ :="|", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumb ers:=True Columns("J:J").Select Selection.Cut Destination:=Columns("H:H")

CopyOrigin:=xlFormatFromLeftOrAbove CopyOrigin:=xlFormatFromLeftOrAbove CopyOrigin:=xlFormatFromLeftOrAbove CopyOrigin:=xlFormatFromLeftOrAbove CopyOrigin:=xlFormatFromLeftOrAbove

For Fila = 6 To 1000 Step 1 Cadena = HojaActual.Cells(Fila, Columna).Value Checksum = 0 For Pos = 1 To Len(Cadena) Step 1 Caracter = Mid(Cadena, Pos, 1) Checksum = Checksum Xor Asc(Caracter) Next HojaActual.Cells(Fila, Columna - 3).Value = Str(Checksum) HojaActual.Cells(Fila, Columna - 2).Value = Hex(Checksum) Next Range("I7:I1500").Select Selection.TextToColumns Destination:=Range("I7"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _ Semicolon:=False, Comma:=True, Space:=False, Other:=True, OtherChar:= _ "*", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1) , Array(5, 1), _ Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array( 11, 1), Array(12, 1) _ , Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array( _ 19, 1), Array(20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24 , 1), Array(25, 1), _ Array(26, 1), Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Ar ray(31, 1)), _ TrailingMinusNumbers:=True Range("B:C,E:I").EntireColumn.AutoFit Range("I6").Value Range("J6").Value Range("K6").Value Range("L6").Value Range("M6").Value Range("N6").Value Range("O6").Value Range("P6").Value Range("Q6").Value Range("R6").Value Range("S6").Value Range("T6").Value Range("U6").Value Range("V6").Value Range("W6").Value = = = = = = = = = = = = = = = "Fuel Eco" "Max Speed" "Trip Distance" "Max Eng Speed" "Max Eng Speed @Max Speed" "Total Eng Distance" "Init Idle Time" "End Idle Time" "Idle Trip Time" "Trip Fuel Used" "Drive Fuel Used" "Mov PTO Used" "Non Mov PTO Used" "Idle Fuel Used" "Cruise Fuel Used"

Range("X6").Value = "Total Eng Hours" Range("Y6").Value = "Total Fuel Used" Range("Z6").Value = "Total Idle Fuel Used" Range("AA6").Value = "Total PTO Fuel Used" Range("AB6").Value = "Total PTO Time" Range("AC6").Value = "Trip Time" Range("AD6").Value = "Fuel Level"

Range("AE6").Value = "Marca" Range("AF6").Value = "Modelo" Range("AG6").Value = "No. Serie" Range("AH6").Value Range("AI6").Value Range("AJ6").Value Range("AK6").Value Range("AL6").Value = = = = = "Unit Number" "VIN" "Min Fuel Lvl" "Trip Fuel Eco" "Trip Fuel Used"

Range("AM6").Value = "Trip Fuel Eco" Range("AN6").Value = "Fuel Level" Range("AO6").Value = "Min Fuel Level" Next End Sub