View Single Post
  #20   Report Post  
Posted to microsoft.public.excel.misc
Mr. Low Mr. Low is offline
external usenet poster
 
Posts: 505
Default Excel 2002 : How to get the difference in a block of data ?

Hello Don,

All answer were correct except the first verhicle .


Vehicle Meter Mileage
BBN2361 9,650 950 < error: the correct answer should be 3,150
BBN2361 10,600
BBN2631 12,800
BSK1400 8,500 8350 < correct
BSK1400 12,500
BSK1400 11,500
BSK1400 14,200
BSK1400 10,250
BSK1400 16,850
BGA2367 12,500 4350 < correct
BGA2367 12,500
BGA2367 12,500
BGA2367 16,850
BFA2129 8,200 8700 < correct
BFA2129 10,200
BFA2129 14,800
BFA2129 16,900
BCA7114 3,200 1300 < correct
BCA7114 4,500

Do you know the reason of the error ?

Note: Formula at C2:
=IF(COUNTIF($A$2:A2,A2)1,"",MAX(IF($A$2:$A$20=A2, $B$2:$B$20))-MIN(IF($A$2:$A$20=A2,$B$2:$B$20)))



Thanks

Low

--
A36B58K641


"Don Guillett" wrote:

Change to absolutes as shown
=IF(COUNTIF($A$2:A2,A2)1,"",MAX(IF($A$2:$A$20=A2, $B$2:$B$20))-MIN(IF($A$2:$A$20=A2,$B$2:$B$20)))

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
or this array formula which will put the total at the 1st instance of the
category instead of the last instance.
=IF(COUNTIF($A$2:A2,A2)1,"",MAX(IF(A2:A21=A2,B2:B 21))-MIN(IF(A2:A21=A2,B2:B21)))
Then the group could be filtered.
--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
Thanks. How about this from a list but no sorting required.
Of course, this is an array formula so it must be entered with
ctrl+shift+enter

=MAX(IF(A2:A221=A2,B2:B221))-MIN(IF(A2:A221=A2,B2:B221))

--
Don Guillett
SalesAid Software

"CLR" wrote in message
...
Cool, Don.........but as with my formula solution, the data must be
pre-sorted and all PN's the same with no leading/trailing space
differences..........

Vaya con Dios,
Chuck, CABGx3



"Don Guillett" wrote:

This should do it.

Sub SumByCategory()
lr = Cells(Rows.Count, "a").End(xlUp).Row + 1
mr = 2
Do Until Cells(mr, 2) = 0
mname = Cells(mr, 1)
nr = Columns(1).Find(mname, after:=Cells(lr, 1), _
searchdirection:=xlPrevious).Row
Cells(nr, 3) = Cells(nr, 2) - Cells(mr, 2)
mr = nr + 1
Loop
End Sub
--
Don Guillett
SalesAid Software

"Mr. Low" wrote in message
...
Dear Sir,

I have the following worksheet data:

A B C D

Vehicle Speedometer Mileage
1 BBN2361 9650
2 BBN2361 10600
3 BBN2631 12800 xxxxx (+B3-B1)
4 BSK1400 8500
5 BSK1400 9320
6 BSK1400 10250 xxxxx (+B6-B4)
7 BGA2367 12500
8 BGA2367 14260
9 BGA2367 16850 xxxxx (+B9-B7)

The mileage is calculated by getting the difference between the last
and
the
first speedometer reading of the same verhicle.

May I know if there is any formula that I can input at C1 and copy
down to
get straight annswer at C3, C6 and C9 ? Other cells in column C is
left
blank.


Thanks

Low



--
A36B58K641