#1   Report Post  
nono
 
Posts: n/a
Default Adding Sum

I made a query report with unique records to display,I don't want repeating
item displayed in the report.
What should I do to sum the other qty delivered in a single item.

Item Qty Date
Pork 50 08/01/05
60 08/10/05
20 08/15/05

should be

Item Qty Date
Pork 130 08/01/05 - 08/15/05

thanks & Godspeed.
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

One way

Sub Test()
Dim iLastRow As Long
Dim i As Long
Dim dteMax As Date
Dim dteMin As Date
Dim nAmount As Double
Dim sCat As String
Dim iRow As Long

Columns("D:F").Insert
iLastRow = Cells(Rows.Count, "B").End(xlUp).Row
dteMax = Range("C2").Value
dteMin = Range("C2").Value
nAmount = Range("B2").Value
sCat = Range("A2").Value
iRow = 1
For i = 3 To iLastRow
If Cells(i, "A").Value = "" Then
nAmount = nAmount + Cells(i, "B").Value
If Cells(i, "C").Value dteMax Then
dteMax = Cells(i, "C").Value
ElseIf Cells(i, "C").Value < dteMin Then
dteMin = Cells(i, "C").Value
End If
Else
Cells(iRow, "D").Value = sCat
Cells(iRow, "E").Value = nAmount
Cells(iRow, "F") = Format(dteMin, "mm/dd/yy") & " - " & _
Format(dteMax, "mm/dd/yy")
sCat = Cells(i, "A").Value
nAmount = 0
dteMax = Cells(i, "C").Value
dteMin = Cells(i, "C").Value
iRow = iRow + 1
End If
Next i
Cells(iRow, "D").Value = sCat
Cells(iRow, "E").Value = nAmount
Cells(iRow, "F") = Format(dteMin, "mm/dd/yy") & " - " & _
Format(dteMax, "mm/dd/yy")

End Sub



--
HTH

Bob Phillips

"nono" wrote in message
...
I made a query report with unique records to display,I don't want

repeating
item displayed in the report.
What should I do to sum the other qty delivered in a single item.

Item Qty Date
Pork 50 08/01/05
60 08/10/05
20 08/15/05

should be

Item Qty Date
Pork 130 08/01/05 - 08/15/05

thanks & Godspeed.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help neede with adding times rvnwdr Excel Discussion (Misc queries) 1 June 17th 05 02:15 PM
adding summed cells in a conditional sumif Tat Excel Worksheet Functions 5 June 12th 05 06:09 PM
problem adding rvnwdr Excel Discussion (Misc queries) 2 June 8th 05 06:36 PM
Adding up Sums AlyG Excel Worksheet Functions 3 June 7th 05 06:31 AM
adding only positive numbers Jacob Excel Discussion (Misc queries) 2 November 30th 04 12:24 AM


All times are GMT +1. The time now is 12:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"