Pregunta para Luis Mondelo: Cambio estado y sumar

Hola Luis Mondelo. Me enviaste esta Macro. Resulta que al ejecutar por segunda vez la macro me borra lo que había sumado. (Estando con la misma fecha) Se puede dejar que al no encontrar otra fecha distinta (b1) deje la suma tal cual?

Sub proceso()
'por luismondelo
fecha = Sheets("hoja2").Range("b1").Value
Sheets("hoja1").Select
Range("c2").Select
Do While ActiveCell.Value <> ""
If UCase(ActiveCell.Value) = "CARTERA" And ActiveCell.Offset(0, 3) <= fecha Then
ActiveCell.Value = "DEP/PAG"
ActiveCell.Offset(0, 2).Value = 0
    If ActiveCell.Offset(0, 3).Value = fecha Then
    suma = suma + ActiveCell.Offset(0, 1).Value
    End If
End If
ActiveCell.Offset(1, 0).Select
Loop
Sheets("hoja2").Range("b3").Value = suma
End Sub

Respuesta
1

Inténtalo con la macro así:

Sub proceso()
'por luismondelo
fecha = Sheets("hoja2").Range("b1").Value
Sheets("hoja1").Select
Range("c2").Select
Do While ActiveCell.Value <> ""
If UCase(ActiveCell.Value) = "CARTERA" And ActiveCell.Offset(0, 3) <= fecha Then
ActiveCell.Value = "DEP/PAG"
ActiveCell.Offset(0, 2).Value = 0
    If ActiveCell.Offset(0, 3).Value = fecha Then
    suma = suma + ActiveCell.Offset(0, 1).Value
    End If
End If
ActiveCell.Offset(1, 0).Select
Loop
if suma <> 0 then Sheets("hoja2").Range("b3").Value = suma
End Sub

He hecho una rectificación:

Sub proceso()
'por luismondelo
suma =0
fecha = Sheets("hoja2").Range("b1").Value
Sheets("hoja1").Select
Range("c2").Select
Do While ActiveCell.Value <> ""
If UCase(ActiveCell.Value) = "CARTERA" And ActiveCell.Offset(0, 3) <= fecha Then
ActiveCell.Value = "DEP/PAG"
ActiveCell.Offset(0, 2).Value = 0
    If ActiveCell.Offset(0, 3).Value = fecha Then
    suma = suma + ActiveCell.Offset(0, 1).Value
    End If
End If
ActiveCell.Offset(1, 0).Select
Loop
if suma <> 0 then Sheets("hoja2").Range("b3").Value = suma
End Sub

No me resulta. Se me desaparece la suma si vuelto a ejecutar. ( Estoy ocupando la ultima macro que me dejaste)

Disculpa. Otra consulta se puede hacer referencia a consultar más de una fecha. Es decir en este momento la macro esta llamando a sumar 1 fecha según la celda b1. Se podría llamar una fecha desdá- hasta ejemplo desde 01-09-2014 hasta el 03-09-2014. En este caso ( seria fechas en celda b1 y celda c1). ahí me dice si se puede y hago otra pregunta. Me interesa esto ultimo ya me tope con ese inconveniente.

Gracias

Mándame un excel con unos cuantos datos, como en el ejemplo para trabajar sobre él y mandarte la solución. Haz un ejemplo manual de lo que quieres

[email protected]

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas