hacer una grafica en excel desde vb6
Publicado por esbon (1 intervención) el 26/06/2017 22:29:23
Buenas tardes compañeros soy nuevo tanto en el foro como en programacion. por medio del siguiente codigo logre generar una tabla desde vb. necesito generar una grafica de los valores de porcentajes en forma descendente. de ante mano les quedo agradecido por la ayuda.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
a = InputBox("ingresar fallas sistema motor")
b = InputBox("ingresar fallas sistema de transmision")
c = InputBox("ingresar fallas sistema de direccion")
d = InputBox("ingresar fallas sistema de suspension")
E = InputBox("ingresar fallas sistema neumatico")
f = InputBox("ingresar fallas sistema electrico")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.Workbooks.Add
Set hoja = objExcel.activesheet
irow = 1
hoja.Cells(irow + 1, 2) = "SISTEMA"
hoja.Cells(irow + 2, 2) = "Motor"
hoja.Cells(irow + 3, 2) = "Transmision"
hoja.Cells(irow + 4, 2) = "Direccion"
hoja.Cells(irow + 5, 2) = "Suspension"
hoja.Cells(irow + 6, 2) = "Neumatico"
hoja.Cells(irow + 7, 2) = "Electrico"
hoja.Cells(irow + 8, 2) = "TOTAL"
hoja.Cells(irow + 1, 3) = "FALLAS"
hoja.Cells(irow + 1, 4) = "PORCENTAJE %"
hoja.Cells(irow + 1, 5) = "ACUMULADO %"
hoja.Cells(irow + 2, 3) = a
hoja.Cells(irow + 3, 3) = b
hoja.Cells(irow + 4, 3) = c
hoja.Cells(irow + 5, 3) = d
hoja.Cells(irow + 6, 3) = E
hoja.Cells(irow + 7, 3) = f
hoja.Cells(irow + 8, 3) = hoja.Cells(irow + 2, 3) + hoja.Cells(irow + 3, 3) + hoja.Cells(irow + 4, 3) + hoja.Cells(irow + 5, 3) + hoja.Cells(irow + 6, 3) + hoja.Cells(irow + 7, 3)
hoja.Cells(irow + 2, 4) = (hoja.Cells(irow + 2, 3) / hoja.Cells(irow + 8, 3)) * 100
hoja.Cells(irow + 3, 4) = (hoja.Cells(irow + 3, 3) / hoja.Cells(irow + 8, 3)) * 100
hoja.Cells(irow + 4, 4) = (hoja.Cells(irow + 4, 3) / hoja.Cells(irow + 8, 3)) * 100
hoja.Cells(irow + 5, 4) = (hoja.Cells(irow + 5, 3) / hoja.Cells(irow + 8, 3)) * 100
hoja.Cells(irow + 6, 4) = (hoja.Cells(irow + 6, 3) / hoja.Cells(irow + 8, 3)) * 100
hoja.Cells(irow + 7, 4) = (hoja.Cells(irow + 7, 3) / hoja.Cells(irow + 8, 3)) * 100
hoja.Cells(irow + 2, 5) = hoja.Cells(irow + 2, 4)
hoja.Cells(irow + 3, 5) = hoja.Cells(irow + 2, 4) + hoja.Cells(irow + 3, 4)
hoja.Cells(irow + 4, 5) = hoja.Cells(irow + 2, 4) + hoja.Cells(irow + 3, 4) + hoja.Cells(irow + 4, 4)
hoja.Cells(irow + 5, 5) = hoja.Cells(irow + 2, 4) + hoja.Cells(irow + 3, 4) + hoja.Cells(irow + 4, 4) + hoja.Cells(irow + 5, 4)
hoja.Cells(irow + 6, 5) = hoja.Cells(irow + 2, 4) + hoja.Cells(irow + 3, 4) + hoja.Cells(irow + 4, 4) + hoja.Cells(irow + 5, 4) + hoja.Cells(irow + 6, 4)
hoja.Cells(irow + 7, 5) = hoja.Cells(irow + 2, 4) + hoja.Cells(irow + 3, 4) + hoja.Cells(irow + 4, 4) + hoja.Cells(irow + 5, 4) + hoja.Cells(irow + 6, 4) + hoja.Cells(irow + 7, 4)
'Opcional : damos formato
'Como ejemplo a la cabecera
hoja.Rows(1).Font.Bold = True
hoja.Rows(1).Font.Color = vbRed 'Autoajustamos
hoja.Columns("A:Z").AutoFit
objExcel.Visible = True
objExcel.ActiveWorkbook.SaveAs "D:\esbon\word\proyecto\mtto\v1\pareto.xls"
Set hoja = Nothing
Set xlibro = Nothing
Set objExcel = Nothing
Valora esta pregunta
0