SUMA CONDICIONAL 2 CONDICIONES

Renzo G

New Member
Joined
May 6, 2002
Messages
19
JP,

Tengo una tabla de 2 columnas, en la primera estan las horas (formato horas) en la segunda columna el numero de elementos que llegaron a esa hora.
Lo que quiero es hacer una tabla de resumen tipo histograma que sume los elementos en intervalos de 30 minutos.
Gracias de antemano,

Renzo
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

t4373125

Board Regular
Joined
Jun 26, 2002
Messages
52
Hola.

Prueba esta macro y dime si hay algo que no entiendas. Puedes modificar los valores iniciales para que se adapte a tus necesidades.

Sub ResumenHoras()

Dim Hora As Date
Dim i As Integer

i = 2
'especificar la primera hora del resumen
Hora = #8:00:00 AM#
Range("E" & i).Value = Hora

'comenzar a analizar los datos
Range("A2").Select

'mientras queden datos
While ActiveCell.Value <> ""
'caso que no se tenga que cambiar la hora
If ActiveCell.Value < Hora + #12:30:00 AM# Then
'sumar la cantidad
Range("F" & i).Value = Range("F" & i).Value + ActiveCell.Offset(0, 1).Value
'caso que se tenga que cambiar de hora
Else
'nueva hora
i = i + 1
Hora = Hora + #12:30:00 AM#
Range("E" & i).Value = Hora
While ActiveCell.Value >= Hora + #12:30:00 AM#
'nueva hora
i = i + 1
Hora = Hora + #12:30:00 AM#
Range("E" & i).Value = Hora
Wend
'sumar la cantidad
Range("F" & i).Value = Range("F" & i).Value + ActiveCell.Offset(0, 1).Value
End If
'ir al siguiente valor
ActiveCell.Offset(1, 0).Select
Wend

End Sub


Un saludo.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,964
Messages
5,599,071
Members
414,281
Latest member
Engjamal2021

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top