Cumulative sum with a ceiling

G

Guest

Hello,
I need help please, with a formula which calculates the cumulative sum of a
column of distances in kilometers.
When the cumulative total reaches a celing of 350kms, it must restart the
cumlulative total again.
If any distance is greater than 350kms then it must give the cumulative
total excluding the greater value, and highlight the cell, show the greater
value in a seperate column and restart the cumulative count again.

My opbjective is to plan a travel route over 5000kms and a scheduled stop
every 350kms for the night. This is to plan where I will be stopping over to
make the booking in advance.

Thank you for your help.

Max
 
T

T. Valko

See if this helps.

Assume the distances are in the range A1:A20

Enter this formula in B1:

=A1

Enter this formula in B2 and copy down to B20:

=IF(SUM(B1,A2)<=350,SUM(B1,A2),A2)

Now, highlight the cells in column A where the sum resets.

Select the range A2:A20
Goto Format>Conditional Formatting
Formula Is: =A2=B2
Click the Format button
Select the style(s) desired
OK out

Biff
 
G

Guest

Perhaps you could do something like this...

Assuming your column of distances starts at A2 then in B2 use this formula

=SUM(A$2:A2)-SUMIF(B$1:B1,">=350")

and in C2

=IF(B2>=350,B2,"")

copy both formulas down as far as necessary

then

use conditional formatting on column B using

"cell value is" "greater than or equal to" 350

then

setting font and pattern to the same colour, e.g. red
 
S

Sandy Mann

Max said:
I need help please, with a formula

I can't help with a formula but wold a Macro do?

Sub AddIt()
Dim EndRow As Long
Dim n As Long
Dim Tot As Double
Dim x As Long
Dim s As Long

EndRow = Cells(Rows.Count, 6).End(xlUp).Row

Range("G:G").ClearContents

n = 0
'Set s to Start Row of your data
s = 10

Tot = 0

For x = s To EndRow
If Tot + Cells(x, 6).Value <= 350 Then
Tot = Tot + Cells(x, 6).Value
Else: Cells(x - n, 7).Value = Tot
Tot = Cells(x, 6).Value
End If
n = 1
Next x

End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(e-mail address removed)
(e-mail address removed) with @tiscali.co.uk
 
D

Dana DeLouis

My objective is to plan a travel route over 5000kms and a scheduled stop
every 350kms for the night.

May I suggest an alternative if your travel is in the USA?
I would recommend mapping software, such as "Street Atlas 2007." from
DeLorme ( http://www.delorme.com )
Microsoft also has a similar product, but I've not used it. (
http://www.microsoft.com/streets/default.mspx )
You can tell such programs you would like to drive 350km per day, and it
will plan all your stops on the map.
You can also give your car's gas mileage, etc, and it will plan gas stops as
well.
Your map will display all the planned stops.
Right click the area of the map where you plan to spend the night, and it
will pull up all hotels in the area, complete with address/phone numbers.
Again, just an idea.
 
C

Chip Pearson

Microsoft also has a similar product, but I've not used it. (

MapPoint will do all that and more. One of the more intriguing features of
MapPoint is that it connects to the internet and downloads (from where I
don't know) road construction info, alerting you to the fact that a
particular highway may have construction delays. It allows you to assign
speeds to different road types (e.g., 70 mph for Interstates and 30 for side
streets), and will compute travel time based on which type of roads you'll
be driving on. MapPoint is one of favorite Office programs.



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top