Find first cell above current row with Number in it and then perform calcs using other cells (I'll explain in the post)

Carlos5

Board Regular
Joined
Jan 14, 2015
Messages
58
Hello all,
Hopefully I can explain this right.
I have a home made mileage/maintenance log.
1.) Column B has the dates I filled up with gas or had maintenance done etc. (One item per row).
2.) Column F has the Gallons added. (If no gas was bought, this cell is empty.)
3.) Column O is days between fill up.
My problem is figuring days between fill up. I am trying to write a formula in Column O (days between fill up) that will see if that row has a number in the gallons column (F) and if it does, find the first cell in F above that also has a number in it. then calc the number of days between the dates in column B, thus giving me my answer.
Is this possible? Have I overthought something? Am I going about this the wrong way? Does any of this make sense?
Any help would be appreciated.
Thanks!

Here is the minisheet (I hope)
New milage calculator in progress.xlsx
BCDEFGHIJKLMNOPQ
3DateOdometer ReadingTrip MeterOdometer MilesGallonsPrice per GallonMisc. Extra Gas FeeGas CostService ClassService provided / Item PurchasedService CostVendorMPGDays between fill upNotestest
44/7/2016135394.00.0#VALUE!0.000$0.000 PurchaseBought Truck$4,500.00Private person #VALUE!Bought truckTRUE
54/8/2016135434.040.040.022.199$2.759$0.35$61.60GasGasArcona1TRUE
64/8/2016135434.00.040.0 RegistrationRegistration$105.00DMV  FALSE
74/8/2016135434.00.040.0 Smog TestSmog Test$48.95Express Lube  FALSE
84/9/2016135434.00.040.0 UpgradeWiring Harness$13.07Auto Zone  FALSE
94/9/2016135434.00.040.0 MaintenanceMaint. Manuals$65.37Pep Boys  FALSE
104/9/2016135434.00.040.0 CosmeticDoor Guards$6.52Pep Boys  FALSE
114/9/2016135434.00.040.0 MaintenanceNeg. Battery Wire$7.61Pep Boys  FALSE
124/10/2016135434.00.040.0 MaintenanceHood lifters$43.58Pep Boys  FALSE
134/10/2016135434.00.040.0 Maintenance$ New Tires$670.00Western Tire  FALSE
144/12/2016135434.00.040.0 CosmeticBlind spot mirrors$4.35Pep Boys  FALSE
154/12/2016135434.00.040.0 SecurityTailgate Lock$21.79Pep Boys  FALSE
164/13/2016135434.00.040.0 InsuranceInsurance$80.00AAA  FALSE
174/13/2016135434.00.040.0 MaintenanceSpare Tire$30.00Tony's Tires  FALSE
184/14/2016135434.00.040.0 MaintenanceSpare Tire$35.00Diamond Tires  FALSE
194/14/2016135434.00.040.0 MaintenanceLug Wrench$9.79Pep Boys  FALSE
204/15/2016135434.00.040.0 CosmeticCenter console$16.34Pep Boys  FALSE
214/15/2016135600.00.0166.012.524$2.699$0.35$34.15GasGasArco13.255 TRUE
224/17/2016135718.00.0118.07.870$2.699$0.35$21.59GasGasArco14.9942TRUE
234/19/2016135718.00.0118.0 MaintenanceSpark Plugs$14.32Pep Boys  FALSE
244/19/2016135718.00.0118.0 MaintenanceAntenna$10.89Pep Boys  FALSE
254/19/2016135718.00.0118.0 MaintenanceSpare tire tools$6.52Pep Boys  FALSE
264/20/2016135718.00.0118.0 MaintenanceRecirculating Door$33.08Amazon  FALSE
274/22/2016135718.00.0118.0 MaintenanceDoor lock actuators (2)$9.55Amazon  FALSE
284/25/2016135718.00.0118.0 MaintenanceReverse Light bulbs & Window handle retaining clips$10.88Pep Boys  FALSE
294/27/2016135718.00.0118.0 MaintenanceReverse Light bulbs$6.53Pep Boys  FALSE
304/30/2016136071.0353.0353.025.015$2.699$0.35$67.87GasGasArco14.1123TRUE
315/21/2016136402.0331.0331.025.081$2.699$0.35$68.04GasGasArco13.19721TRUE
326/5/2016136755.0352.8353.024.900$2.699$0.35$67.56GasGasArco14.17715TRUE
336/21/2016137127.0371.7372.024.355$2.739$0.35$67.06GasGasArco15.27416TRUE
Data
Cell Formulas
RangeFormula
N4,N6:N33N4=IFERROR(E4/F4,"")
O4:O33O4=IF([@Gallons]="","",IF([@Date]-B3=0,"",[@Date]-B3))
E4:E33E4=IF(C4-C3=0,E3,C4-C3)
I4:I33I4=IF(([@[Price per Gallon]]*[@Gallons])+[@[Misc. Extra Gas Fee]]=0,"",([@[Price per Gallon]]*[@Gallons])+[@[Misc. Extra Gas Fee]])
Q4:Q33Q4=ISNUMBER(F4)
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
How about
Excel Formula:
=IF([@Gallons]="","",[@Date]-LOOKUP(2,1/(F$3:F3<>""),B$3:B3))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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