Visual Basic - el for del final no funciona

Life is soft - evento anual de software empresarial
 
Vista:

el for del final no funciona

Publicado por martha (1 intervención) el 16/12/2008 14:17:28
hola,

tengo un problema grandisimo. el siguiente codigo busca una serie de valores en una hoja y los guarda en otra esto lo debe realizar para cada poliza, pero el for del final no funciona, pues activo mas de una hoja entonces la fila activa despues de que corre la primer vez cambia y es ota que no tiene nada que ver.

agradesco su ayuda. es realmente urgente

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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
Sub guardar(monto As Variant, j As Integer)
 
j = j - 1
Worksheets("Tarifa_Basico").Activate
ActiveSheet.Range("AT1").Activate
 
With ActiveCell
  .Offset(j, 0).Value = monto
End With
 
End Sub
 
Sub clear()
Worksheets("Tarifa_Basico").Activate
ActiveSheet.Range("AT1").Activate
 
 Do While Not IsEmpty(ActiveCell)
 
     With ActiveCell
    .Offset(0, 0).Value = 0
    End With
 
    ActiveCell.Offset(1, 0).Activate
    Loop
End Sub
 
 Function saltar_celdas_llenas1(j As Integer) As Integer
 
     Worksheets("Base_Retiros").Activate
     Worksheets("Base_Retiros").Rows(j).Activate
 
 
 
     Do While Not IsEmpty(ActiveCell)
 
     ActiveCell.Offset(0, 1).Activate
      Loop
 
     saltar_celdas_llenas1 = ActiveCell.Column
 
 End Function
 
 Sub read_ret1(casilla As String, col As Integer)
 
 
 
   Dim monto  As Variant
     Dim fecha As Variant
   Dim rowd As Integer
   Dim Columnd As Integer
 
    Dim proof As Integer
    Dim proof1 As Integer
    Dim sum As Boolean
 
 
 
 
 
    Worksheets("Base_Retiros").Activate
 
    ActiveSheet.Range(casilla).Activate
 
 
 
 
 
         With ActiveCell
 
 
                proof = .Offset.Row
                proof1 = .Offset.Column
 
                fecha = .Offset(0, col)
                monto = .Offset(0, col - 1)
 
                 If Not IsEmpty(monto) Then
 
 
                   With Worksheets("Tarifa_Basico").Range("AQ1:AQ300")
                      Set d = .Find(fecha, LookIn:=xlValues)
                           If Not d Is Nothing Then
                            firstAddress = d.Address
                             Do
                            rowd = d.Row
                            Columnd = d.Column
 
 
                            Call guardar(monto, rowd)
 
 
                         Loop While Not d Is Nothing And d.Address <> firstAddress
                        End If
                  End With
 
 
             Else
 
                   sum = True
 
            End If
 
     End With
 
End Sub
 
 
Sub apesta(poliza As Variant)
 
    Dim rowr As Integer
    Dim rowp As Integer
    Dim col As Integer
    Dim j As Integer
    Dim casilla As String
 
 
 
 
 
    Worksheets("Base_Retiros").Activate
 
    ActiveSheet.Range("a1").Activate
 
 
     Do While Not IsEmpty(ActiveCell) And ActiveCell.Value <> poliza
    ActiveCell.Offset(1, 0).Activate
    Loop
 
     col = 0
 
     With ActiveCell
 
      casilla = ActiveCell.Address
      rowp = ActiveCell.Row
 
 
     col = 2
 
     rowr = saltar_celdas_llenas1(rowp)
 
     j = (rowr / 2) - 1
 
     For i = 1 To j
 
 
      Call read_ret1(casilla, col)
 
 
      col = col + 2
 
 
      Next i
 
   End With
 
End Sub
 
 
Sub datos_entrada(casi1 As String)
'
' datos_entrada Macro
' Macro grabada el 28/11/2008 por sole
'
'
  Dim poliza As Variant
  Dim col As Integer
 
     Dim k As String
 
 
 
  Worksheets("Bases Datos").Activate
  ActiveSheet.Range(casi1).Activate
 
  col = 0
   For i = 1 To 30
     With ActiveCell
 
 
            Worksheets("Datos de Entrada").Range("D3").Value = .Offset(0, 10)
            Worksheets("Datos de Entrada").Range("D4").Value = .Offset(0, 38)
             Worksheets("Datos de Entrada").Range("D5").Value = .Offset(0, 27)
            Worksheets("Datos de Entrada").Range("D6").Value = .Offset(0, 11)
            Worksheets("Datos de Entrada").Range("D7").Value = .Offset(0, 33)
            Worksheets("Datos de Entrada").Range("D8").Value = .Offset(0, 6)
            Worksheets("Datos de Entrada").Range("D9").Value = .Offset(0, 15)
 
            poliza = .Offset(0, 5)
 
 
            Call apesta(poliza)
 
             Call clear
 
          col = 1 + col
 
      .Offset(0, 39).Value = Worksheets("Datos de Entrada").Range("J2")
 
          ActiveCell.Offset(col, 0).Activate
 
      Next i
 
 
    End With
 
 
 
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

el for del final no funciona

Publicado por igor (633 intervenciones) el 16/12/2008 20:44:57
gracias!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

el for del final no funciona

Publicado por P3L30N (699 intervenciones) el 16/12/2008 21:28:39
Gracias, porqué?

no me digas que te leiste el toxo entero y te solusionó algún problema que tenias con tu código?

Lo que yo no he logrado entender es lo siguiente:

"...pues activo mas de una hoja entonces la fila activa despues de que corre la primer vez cambia y es ota que no tiene nada que ver. "
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar