Cumulative Totalling (how to...)

alagoritma

New Member
Joined
Feb 2, 2005
Messages
2
Hello all,

Good days...

Subject: How to cumulate a time based variable within its limits via VBA code?

Assume that I have two columns (A & B); A is for time stamp of the values and B holds the values...

A B
1 12:43 23.92
2 12:44 23.93
3 12:45 23:91

My question is: How to integrate the values within a time interval, from a starting time to a ending time?

I have seen some replies, as if an answer to my question but frankly I could not manage the code...Is any there gentle(wo)man, helping me?...:)

Thanks...


Regards,


Hilmi
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Harvey

Well-known Member
Joined
Nov 18, 2004
Messages
953
Code:
for each cell in Range(listoftimevalues)
  if cell.value => cellcontainingstartingtime and _
    cell.value <= cellcontainingendingtime then
    sumofthevaluesinthenextcolumn = sumofthevaluesinthenextcolum + cell.offset(1,0)
  end if
next cell
 

alagoritma

New Member
Joined
Feb 2, 2005
Messages
2
Harvey,

Your "narrative" code seems pretty may be...but still I need a translator...

Do you mind sending me a running example, if posssible?...:)

Thanks....
 

Harvey

Well-known Member
Joined
Nov 18, 2004
Messages
953
this is how your sheet should look like:
Map2
ABCDEFGH
111:002
213:103
314:104
414:30513:0015:1018
515:096
615:207
Blad1


A1:A6 is the range where the times are in.
B1:B6 (offset 1) is the range where the sum values are in
F4 is where the starting time is in
G4 is where the ending time is in
H4 is where the values will be put

Code:
Sub x()

For Each cell In Range("A1:A6")
  If cell.Value >= Range("F4") And _
    cell.Value<= Range("G4") Then
    sumvalues = sumvalues + cell.Offset(0, 1)
  End If
Next cell

    Range("H4").Value = sumvalues

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,057
Messages
5,599,550
Members
414,316
Latest member
ExcelLee

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