Running Total - involving empty cells, adding and subtracting based on criteria.

Aly

New Member
Joined
Jun 14, 2011
Messages
3
Hi,

I have been asked to create a spread sheet that takes the start and end times of and activity and calculates total time. Along with this, it also need to work out fuel used for each activity.

I am not an excel expert, and have managed so far with functions (mainly IF's). However for working out the fuel used is proving to be far more difficult, as it does not include data in every row for each column, and in addition there is also fuel added from time to time.

I fear that, I am moving into the realm of VBA, which I do not know anything about. So far to calculate fuel used, I have had to create a Fuel at Start column and a Fuel at End column and then some hidden columns where I do the calculations. This part works fine, though having a start and end column is clumsy, as you will see when you look at the sheet.

The section where I become most stuck is then working out the running totals of fuel used, as I need to start adding when more is taken.

If there is anyone who can help me I would be very grateful, sorry to sound ignorant, but I am not at all familiar with VBA and excel, so please be patient and make your response simple!

I am using Excel2003, with Windows XP
Excel Workbook
DEFJKLMNOPQRS
5Levels At StartLevels At EndConsumptionReason
6FOLOFWFOLOFWFOLOFW
7577333318355677333318355Mobilisation
8100000Bunkered
9000Stand By
104043031711039933225250530010530010Full Fee
113208150000Bunkered
12399332252503233247520076750507675050Off Hire
133233247520031632475195705705Full Fee
143163247519581432475192103103Off Hire
15499000Bunkered
168143247519279532475188190124190124Full Fee
17120000Bunkered
1879532475288715312953508011805880118058Off Hire
19120000Bunkered
20000Full Fee
21000WOW
22000Full Fee
23000WOW
2471531295350687312953202803028030Full Fee
25687312953206673129532020002000Off Hire
266673129530766631295307100100Full Fee
276663129530765631145300101507101507Off Hire
286563114530065431145299201201Full Fee
296543114529965431145299Off Hire
30000Full Fee
31000WOW
32000Full Fee
33000WOW
Tracker
Excel 2003
Cell Formulas
RangeFormula
M7=IF($S7="Bunkered",0,IF($S8="Bunkered",(D7+D8)-J7,D7-J7))
N7=IF($S7="Bunkered",0,IF($S8="Bunkered",(E7+E8)-K7,E7-K7))
O7=IF($S7="Bunkered",0,IF($S8="Bunkered",(F7+F8)-L7,F7-L7))
P7=IF(J7=0,"",M7)
Q7=IF(K7=0,"",N7)
R7=IF(L7=0,"",O7)
 
Last edited by a moderator:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Sorry, I have forgotten to add that at the moment, the only way I can make the sheet work is to have "Bunkering" and its values directly bellow the last set of values regardless of date.

This is confusing for the users, I would like to be able to allow "Bunkering" to be placed in its row according to the date, which would mean that it could have unlimited blank cells above and bellow...
 
Upvote 0
Ok, I hope that this is a lot clearer than my first attempt!...

I am creating a spreadsheet which the user can input:
Start dates and time
Start fuel levels
End dates and times
End fuel levels
Type of activity.
The spread sheet will then calculate time for each activity and total time. Fuel used for an activity and keep a running record of total fuel.

Using functions I have been able to set up the sheets to calculate the times of each activity with out an issue, so this part is okay. I have not included it in the example due to the restriction of 13 columns maximum in the HTML creator. I am having problems with the fuel calculations.

The problem I am having is that fuel does not need to be entered for every activity, and so there will be blank data in some rows. This is then compounded that a running total of fuel is also needed. Running total of fuel will also include the addition of fuel (“Bunkering”) which then means the addition of fuel in some rows and the subtraction of fuel in other rows.

This has proved to create several issues:

1) I have created a solution to the fuel used at each activity by forcing the user to input fuel figures at the start of an activity (“Levels At Start”) and again at the end of an activity (“Levels At End”). The fuel used (“Consupmtion”) is a simple subtraction calculation. I have used hidden columns to do the calculation and then only displayed the results if there is a value above 0. However the fuel levels at the end will be the same as the fuel levels entered at the start of the next task. Having to enter the same figure twice is messy. As you can see from the data there may be unlimited rows of other activities where fuel levels are not entered. I have not found a formula that allows me to miss the empty cells in order to take the last entered fuel figures. And then take in to account my second issue:

2) There are also occasions where fuel is added, this then needs to be taken into the fuel used calculation. Again at the moment I have found a temporary solution, where fuel added, must be inserted in the row directly bellow the last entered fuel figures. This again is messy as it does not allow fuel added (or “Bunkered”) to be placed chronologically into the spreadsheet.

I am not in the least bit familiar with VBA, though I do feel that I will need some sort of macro to solve these problems as the formula would be required to search through the columns, find figures, based on certain criteria and then calculate the results accordingly.

Thank you so much for your time and patience.
Excel Workbook
DEFJKLMNOPQRS
5Levels At StartLevels At EndConsumptionReason
6FOLOFWFOLOFWFOLOFW
7577333318355677333318355Mobilisation
8100000Bunkered
9000Stand By
104043031711039933225250530010530010Full Fee
113208150000Bunkered
12399332252503233247520076750507675050Off Hire
133233247520031632475195705705Full Fee
143163247519581432475192103103Off Hire
15499000Bunkered
168143247519279532475188190124190124Full Fee
17120000Bunkered
1879532475288715312953508011805880118058Off Hire
19120000Bunkered
20000Full Fee
21000WOW
22000Full Fee
23000WOW
2471531295350687312953202803028030Full Fee
25687312953206673129532020002000Off Hire
266673129530766631295307100100Full Fee
276663129530765631145300101507101507Off Hire
286563114530065431145299201201Full Fee
296543114529965431145299Off Hire
30000Full Fee
31000WOW
32000Full Fee
33000WOW
Tracker
Excel 2003
Cell Formulas
RangeFormula
M7=IF($S7="Bunkered",0,IF($S8="Bunkered",(D7+D8)-J7,D7-J7))
N7=IF($S7="Bunkered",0,IF($S8="Bunkered",(E7+E8)-K7,E7-K7))
O7=IF($S7="Bunkered",0,IF($S8="Bunkered",(F7+F8)-L7,F7-L7))
P7=IF(J7=0,"",M7)
Q7=IF(K7=0,"",N7)
R7=IF(L7=0,"",O7)
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

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
Back
Top