Algoritmo vb para aplicaciones no funciona
Publicado por Yubell (1 intervención) el 21/04/2016 19:03:31
El codigo no funciona cuando recibo una matriz de un rango de celdas... se rompe cuando entra a la linea que esta en negrita, alguien me puede decir que esta mal?
Estoy usando visual basic para aplicaciones 7.1 con excel 2013
Estoy usando visual basic para aplicaciones 7.1 con excel 2013
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Public Function rigidez1(matriz2)
Dim thisarray As Variant
thisarray = Selection.Value
Dim matriz
matriz = matriz2 '[B2:E8]
Dim pos
Dim pos1
Dim pos2
Dim pos3
pos = -4
pos1 = -3
pos2 = -4
pos3 = -3
For i = 1 To 40
pos = pos + 6
pos1 = pos1 + 6
pos2 = pos2 + 6
pos3 = pos3 + 6
Dim longi
longi = matriz(i, 3)
If (longi = 0) Then Exit For
Cells(pos, 8).Value = Cos((matriz(i, 4) * 3.1416 / 180)) * Sin((matriz(i, 4) * 3.1416 / 180)) / (matriz(i, 3))
Cells(pos1, 7).Value = Cos((matriz(i, 4) * 3.1416 / 180)) * Sin((matriz(i, 4) * 3.1416 / 180)) / (matriz(i, 3))
Cells(pos2, 7).Value = Cos((matriz(i, 4) * 3.1416 / 180)) * Cos((matriz(i, 4) * 3.1416 / 180)) / (matriz(i, 3))
Cells(pos3, 8).Value = Sin((matriz(i, 4) * 3.1416 / 180)) * Sin((matriz(i, 4) * 3.1416 / 180)) / (matriz(i, 3))
Next i
Dim lug
Dim lug1
lug = -2
lug1 = -3
For i = 1 To 40
lug = lug + 6
Dim longit
longit = matriz(i, 3)
If (longit = 0) Then Exit For
lug1 = lug1 + 9
Cells(lug, 9).Value = Cells(lug - 2, 7)
Cells(lug + 1, 9).Value = Cells(lug - 1, 7)
Cells(lug, 10).Value = Cells(lug - 2, 8)
Cells(lug + 1, 10).Value = Cells(lug - 1, 8)
Next i
Dim neg
Dim neg1
neg = -4
neg1 = -5
For i = 1 To 40
neg = neg + 6
Dim longitud
longitud = matriz(i, 3)
If (longitud = 0) Then Exit For
neg1 = neg1 + 9
Cells(neg, 9).Value = (Cells(neg, 7) * -1)
Cells(neg + 1, 9).Value = (Cells(neg + 1, 7) * -1)
Cells(neg, 10).Value = (Cells(neg, 8) * -1)
Cells(neg + 1, 10).Value = (Cells(neg + 1, 8) * -1)
Cells(neg + 2, 7).Value = (Cells(neg + 2, 9) * -1)
Cells(neg + 3, 7).Value = (Cells(neg + 3, 9) * -1)
Cells(neg + 2, 8).Value = (Cells(neg + 2, 10) * -1)
Cells(neg + 3, 8).Value = (Cells(neg + 3, 10) * -1)
Next i
End Function
Valora esta pregunta


0