ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Total up a column as the value change on another (https://www.excelbanter.com/excel-programming/321797-total-up-column-value-change-another.html)

Fernando[_2_]

Total up a column as the value change on another
 
If you don't see the table below properly try Clicking on the
"Original Format" link on the right hand top coner.



I want to write a code to Total up some figures.
Every Change in Date (Column A), Flight No (Column B), Out/In(Column
D),
Column H's figures should total up to "Column I" as it shown in the
example above. Like wise Column J's figures should total up to Column
K.

On Column H there is a formular it values changes automaticaly, but
Column J user enters values. Adding up should be in the same row
because the condition is common to Column I and K.

I hope I made my self clear.

A B D H I J K
Date Flight Out/ Total Total Return Return
No In per per per per
series flight series flight

10.01.05 878 out 6 2
10.01.05 878 out 10 16 3 5
10.01.05 878 in 15 5
10.01.05 878 in 10 4
10.01.05 878 in 10 35 9 18
10.01.05 578 out 15 5
10.01.05 578 out 12 27 3 8
10.01.05 578 in 20 6
10.01.05 578 in 20 40 4 10
11.01.05 878 out 6 2
11.01.05 878 out 10 16 3 5
11.01.05 878 in 10 4
11.01.05 878 in 10 20 9 13
11.01.05 578 out 15 5
11.01.05 578 out 12 27 3 8
11.01.05 578 in 20 6
11.01.05 578 in 20 40 4 10

Thank you very much in advance.

Tom Ogilvy

Total up a column as the value change on another
 
As I asked before, What row does your data start on.

What row has this information
10.01.05 878 out 6 2

Don't repost your question - answer my question.

--
Regards,
Tom Ogilvy


"Fernando" wrote in message
om...
If you don't see the table below properly try Clicking on the
"Original Format" link on the right hand top coner.



I want to write a code to Total up some figures.
Every Change in Date (Column A), Flight No (Column B), Out/In(Column
D),
Column H's figures should total up to "Column I" as it shown in the
example above. Like wise Column J's figures should total up to Column
K.

On Column H there is a formular it values changes automaticaly, but
Column J user enters values. Adding up should be in the same row
because the condition is common to Column I and K.

I hope I made my self clear.

A B D H I J K
Date Flight Out/ Total Total Return Return
No In per per per per
series flight series flight

10.01.05 878 out 6 2
10.01.05 878 out 10 16 3 5
10.01.05 878 in 15 5
10.01.05 878 in 10 4
10.01.05 878 in 10 35 9 18
10.01.05 578 out 15 5
10.01.05 578 out 12 27 3 8
10.01.05 578 in 20 6
10.01.05 578 in 20 40 4 10
11.01.05 878 out 6 2
11.01.05 878 out 10 16 3 5
11.01.05 878 in 10 4
11.01.05 878 in 10 20 9 13
11.01.05 578 out 15 5
11.01.05 578 out 12 27 3 8
11.01.05 578 in 20 6
11.01.05 578 in 20 40 4 10

Thank you very much in advance.




Priyanga Fernando

Total up a column as the value change on another
 
Hello Mr Ogilvy,

I’m sorry I completely miss understood.

Data starts at 5th Row.

Regards,

Fernando



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

Total up a column as the value change on another
 
Sub AddColumnsHandJ()
Dim tot1 as Long, tot2 as Long
Dim i as long
tot1 = 0 : tot2 = 0
for i = 5 to cells(rows.count,1).End(xlup).Row
tot1 = tot1 + cells(i,"H").Value
tot2 = tot2 + cells(i,"J").Value
if cells(i,"A").Value < cells(i+1,"A").Value or _
cells(i,"B").Value < cells(i+1,"B").Value or _
cells(i,"D").Value < cells(i+1,"D").Value then
cells(i,"I").Value = tot1
cells(i,"K").Value = tot2
tot1 = 0 : tot2 = 0
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"Priyanga Fernando" wrote in message
...
Hello Mr Ogilvy,

I'm sorry I completely miss understood.

Data starts at 5th Row.

Regards,

Fernando



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com