Pregunta para Dante Amor: Sumar hasta bajo condiciones múltiples
Hola Dante Amor. Esta macro resulta muy bien, pero mi pregunta estaba mal planteada. En realidad yo quisiera que me sumara hasta la fecha de referencia. No sólo la fecha que indica en la fila 2. Es decir sumar hasta el 24 de Agosto. No buscar sólo los valores que están bajo la fecha 24 de agosto. O Si es muy complicado por último definir las fechas en dos filas distintas desde - hasta. Por ejemplo desde el 01-08-2014 hasta el 14-08-2014.(Fila 1 desde y fila2 hasta) aunque lo primero seria genial. Lo otro si esta macro la ejecuto 2 ó más veces en forma seguidas me va sumando sobre la suma una y otra vez. ¿Se puede resolver eso?. Cosa que si ejecuto dos veces si hay cifras nuevas que actualice y no sume sobre si misma.

Sub proveedores()
'Por.DAM
Set h1 = Sheets("Proveedores")
Set h2 = Sheets("Hoja2")
u = h2.UsedRange.Rows(h2.UsedRange.Rows.Count).Row + 1
v = h2.UsedRange.Columns(h2.UsedRange.Columns.Count).Column + 1
h2.Range(h2.Cells(3, 4), h2.Cells(u, v)).ClearContents
For i = 2 To h1.Range("O" & Rows.Count).End(xlUp).Row
s = h1.Cells(i, "M")
Set b = h2.Range("B:B").Find(h1.Cells(i, "O"), lookat:=xlWhole)
If Not b Is Nothing Then
f = b.Row
Set c = h2.Rows(2).Find(h1.Cells(i, "H"))
If Not c Is Nothing Then
h2.Cells(f, c.Column) = h2.Cells(f, c.Column) + s
End If
Else
Set o = h2.Range("B:B").Find("OTROS", lookat:=xlPart)
If Not o Is Nothing Then
f = o.Row
Set c = h2.Rows(2).Find(h1.Cells(i, "H"))
If Not c Is Nothing Then
h2.Cells(f, c.Column) = h2.Cells(f, c.Column) + s
End If
End If
End If
Next
End Sub
1 respuesta
Respuesta de Dante Amor
1

