2 mileage rates

desert_dweller5

New Member
Joined
Apr 8, 2011
Messages
30
I'm trying to figure out how to figure out my mileage expenses automatically. It's kicking my butt.

Rate 10.54
Limit 1225
rate 20.23

lets start out simply.

every week I have to calculate my mileage expenses. following these rates and limits.
i get 54 cents per mile up to 225 miles in 1 week. after that I get 23 cents per mile. the rates start over the next week. I go back to 54 c / mile on sunday.
the problem comes in when I get to 226 miles for the week

Day of the weekDailyWeekly54 c/mi23 c/mile
Sunday224224=a2*0.54 (+$120.96)0
Monday2226$0.54$0.23
Tuesday12270$0.23
Wednesday12280$0.23
Thursday12290$0.23
Friday12300
$0.23
Saturday12310$0.23
Current total231121.50$1.15
Grand totalMiles this month:231$122.65

this is what the result should look like. values selected for easy math.

also I may have to calculate a limit for 1000 mi / month. if I go over 1000 miles in a month I stop getting paid for that mileage.
I'm not sure where to calculate this on the spread sheet.
I'm not sure what formulas I need to make this happen. I've been at this for weeks and I still cant get it.
thanks for your time.
Desert_dweller5
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
T202011a.xlsm
ABCDEF
1Total limit1000
21- 2250.54
3226 -10000.23
4
5Week1Week2Week3Week4Week5
6Mileage300200100700200
7Payment$138.75$108.00$54.00$161.75$0.00
8
9a
Cell Formulas
RangeFormula
B7:F7B7=IF(AND(B6>0,SUM($A$6:A6)<$B$1),MIN(225,B6)*$B$2+(B6>225)*MIN(B6-225,$B$1-SUM($A$6:A6)-225)*$B$3,0)
 
Upvote 0
Because you can never have too many solutions, here is a VBA.

VBA Code:
Sub Mileage1()

For i = 2 To 8

If Cells(i, 3) <= 225 Then

Cells(i, 4) = Cells(i, 2) * 0.54

ElseIf Cells(i, 3) >= 226 Then

Cells(i, 4) = (Cells(i, 3) - 225) * 0.54
Cells(i, 5) = (Cells(i, 2) - (Cells(i, 3) - 225)) * 0.23
Exit For

End If

Next i
For i = 2 To 7

If Cells(i, 5) <> "" Then

Cells(i + 1, 5) = Cells(i + 1, 2) * 0.23

End If

Next i
End Sub

Book1
ABCDE
1Day of the weekDailyWeekly54 c/mi23 c/mile
2Sunday224224$120.96
3Monday2226$0.54$0.23
4Tuesday1227$0.23
5Wednesday1228$0.23
6Thursday1229$0.23
7Friday1230$0.23
8Saturday1231$0.23
9Current total$121.50$1.38
10Grand totalMiles this month:$122.88
Miliage
Cell Formulas
RangeFormula
C2C2=B2
C3:C8C3=C2+B3
D9D9=IF(D2<>"",SUM(D2:D8),"")
E9E9=IF(E8<>"",SUM(E2:E8),"")
E10E10=IF(E8<>"",D9+E9,"")


Here is another example.

Book1
ABCDE
1Day of the weekDailyWeekly54 c/mi23 c/mile
2Sunday200200$108.00
3Monday20220$10.80
4Tuesday3223$1.62
5Wednesday5228$1.62$0.46
6Thursday1229$0.23
7Friday1230$0.23
8Saturday1231$0.23
9Current total$122.04$1.15
10Grand totalMiles this month:$123.19
Miliage
Cell Formulas
RangeFormula
C2C2=B2
C3:C8C3=C2+B3
D9D9=IF(D2<>"",SUM(D2:D8),"")
E9E9=IF(E8<>"",SUM(E2:E8),"")
E10E10=IF(E8<>"",D9+E9,"")
 
Upvote 0
If you are not concerned after the 1000 mile threshold
Consider one of the following.
It is a little more complex to consider the 1000 mile threshold; see next post.

T202011a.xlsm
ABCDEF
5Week1Week2Week3Week4Week5
6Mileage200300400400200
12
13108.00138.75161.75161.75108.00
14108.00138.75161.75161.75108.00
15108.00138.75161.75161.75108.00
16108.00138.75161.75161.75108.00
9a
Cell Formulas
RangeFormula
B13:F13B13=B6*$B$3+MIN($A$2,B6)*($B$2-$B$3)
B14:F14B14=MIN(B6,$A$2)*$B$2+(B6>$A$2)*(B6-$A$2)*$B$3
B15:F15B15=IF(B6<$A$2,B6*$B$2,(B6-$A$2)*$B$3+$A$2*$B$2)
B16:F16B16=B6*0.23+MIN(225,B6)*0.31
 
Upvote 0
T202011a.xlsm
ABCDEF
1Upper Limit
22250.540.54
310000.23-0.31
4
5Week1Week2Week3Week4Week5
6Mileage200300400400200
7Payment$108.00$138.75$161.75$54.00$0.00
8$108.00$138.75$161.75$54.00$0.00
9$108.00$138.75$161.75$54.00$0.00
10
9a
Cell Formulas
RangeFormula
C2:C3C2=B2-B1
B7:F7B7=IF(AND(B6>0,SUM($A$6:A6)<$A$3),MIN($A$2,B6,$A$3-SUM($A$6:A6))*$B$2+(B6>225)*(($A$3-SUM($A$6:A6)-225)>0)*(B6-225)*$B$3,0)
B8:F8B8=SUMPRODUCT(--(MIN(B6,$A$3-SUM($A$6:A6))>{0;225}),MIN(B6,$A$3-SUM($A$6:A6))-{0;225},{0.54;-0.31})
B9:F9B9=SUMPRODUCT(--(MIN(B6,$A$3-V(SUM($A$6:A6)))>{0;225}),MIN(B6,$A$3-V())-{0;225},$C$2:$C$3)


N.B. Range B9:F9 uses a UDF V(), if your Excel has the new function LET use it instead of V(). To use V() you will need to put the UDF in your file.
 
Upvote 0
So desert dweller, if you have any questions about any of these solutions, let us know.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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