Re: Adding Sum



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" <nono@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0B5D4B71-CF5D-4133-A2A3-0D28AC40FA00@xxxxxxxxxxxxxxxx
> 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.


.



Relevant Pages

  • Re: access mail merge
    ... type mailmerge main document with the mergefields in the cells of a one row ... Dim source As Document, target As Document, scat As Range, tcat As Range ... Dim data As Range, stab As Table, ttab As Table ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Insert line into catalog mail merge
    ... Dim source As Document, target As Document, scat As Range, tcat As Range ... Dim data As Range, stab As Table, ttab As Table ... record1 1 May 2007 ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Merge Word2002
    ... Dim source As Document, target As Document, scat As Range, tcat As Range ... Dim data As Range, stab As Table, ttab As Table ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Printing directory...page break at change of initial cap
    ... it's called Directory) type mailmerge main document with ... Dim source As Document, target As Document, scat As Range, tcat As Range ... Dim data As Range, stab As Table, ttab As Table ... Set data = stab.Cell.Range ...
    (microsoft.public.word.mailmerge.fields)
  • RE: Test if Column B is autofiltered
    ... Sub IsFilteron() ... Dim iLastRow As Double ... This solves my problem.....your work was brilliant Michael. ...
    (microsoft.public.excel.programming)

Loading